From 86679899f5a2d63367c6a8477ecb1d78c8ce683f Mon Sep 17 00:00:00 2001 From: mpl Date: Thu, 27 Apr 2017 19:12:06 +0200 Subject: [PATCH] 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 --- server/camlistored/ui/goui/sharebutton/sharebutton.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/camlistored/ui/goui/sharebutton/sharebutton.go b/server/camlistored/ui/goui/sharebutton/sharebutton.go index 5915df25d..0a8707f0f 100644 --- a/server/camlistored/ui/goui/sharebutton/sharebutton.go +++ b/server/camlistored/ui/goui/sharebutton/sharebutton.go @@ -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 }