mirror of https://github.com/perkeep/perkeep.git
camlistored/ui: fix share URL dialog for all pages
The code to find the prefix URL that is used to display the share URL on after successfully sharing an item, worked only on the main web UI page. This change makes it work on hopefully any page. Change-Id: I05e085f91ef7ebe39f880104e52ca487b80c607a
This commit is contained in:
parent
eafdd2a524
commit
86679899f5
|
@ -165,7 +165,7 @@ func (d *ShareItemsBtnDef) handleShareSelection(*react.SyntheticMouseEvent) {
|
|||
}
|
||||
prefix, err := d.urlPrefix()
|
||||
if err != nil {
|
||||
println(fmt.Sprintf("Cannot display full share URL: %v", err))
|
||||
dom.GetWindow().Alert(fmt.Sprintf("Cannot display full share URL: %v", err))
|
||||
return
|
||||
}
|
||||
sharedURL = prefix + sharedURL
|
||||
|
@ -297,9 +297,9 @@ func (d *ShareItemsBtnDef) urlPrefix() (string, error) {
|
|||
if strings.HasSuffix(currentURL, uiRoot) {
|
||||
return strings.TrimSuffix(currentURL, uiRoot), nil
|
||||
}
|
||||
parts := strings.SplitN(currentURL, uiRoot, 1)
|
||||
if len(parts) < 2 {
|
||||
idx := strings.Index(currentURL, uiRoot)
|
||||
if idx == -1 {
|
||||
return "", fmt.Errorf("could not guess our URL prefix")
|
||||
}
|
||||
return parts[0], nil
|
||||
return currentURL[:idx], nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue