mirror of
https://github.com/wahyd4/golink.git
synced 2026-08-08 21:01:05 +10:00
golink: ignore hyphens and allow changing name
- ignore hyphens, preventing link ambiguity. If hyphens are included when creating the link, they are saved as the "canonical" name for the link, but links are still resolved without them. - allow overwriting the "canonical" name for a short link by simply recreating it with the new canonical name. Stats are not updated when the canonical name is updated, which is probably fine. Change-Id: Ia962caa846489850784ef15cdfad7f13bafd8842
This commit is contained in:
@@ -148,6 +148,7 @@ http://go/<input name=short size=20 value="{{.Short}}"> ==> <input name=long
|
||||
|
||||
func linkPath(short string) string {
|
||||
name := url.PathEscape(strings.ToLower(short))
|
||||
name = strings.ReplaceAll(name, "-", "")
|
||||
name = strings.ReplaceAll(name, ".", "%2e")
|
||||
return filepath.Join(*linkDir, name)
|
||||
}
|
||||
@@ -302,6 +303,7 @@ func serveSave(w http.ResponseWriter, r *http.Request) {
|
||||
Created: now,
|
||||
}
|
||||
}
|
||||
dl.Short = short
|
||||
dl.Long = long
|
||||
dl.LastEdit = now
|
||||
dl.Owner = login
|
||||
|
||||
Reference in New Issue
Block a user