mirror of
https://github.com/garraflavatra/rolens.git
synced 2025-01-18 21:17:59 +00:00
Parse connection URI correctly
This commit is contained in:
parent
958a0197a4
commit
48b26c9df5
@ -2,10 +2,10 @@ package app
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
@ -56,12 +56,16 @@ func (a *App) ExecuteShellScript(hostKey, dbKey, collKey, script string) (result
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
connstr := host.URI
|
url, err := url.Parse(host.URI)
|
||||||
if !strings.HasSuffix(connstr, "/") {
|
if err != nil {
|
||||||
connstr = connstr + "/"
|
runtime.LogWarningf(a.ctx, "Shell: failed to parse host URI %s: %s", host.URI, err.Error())
|
||||||
|
result.ErrorTitle = "Could parse host URI"
|
||||||
|
result.ErrorDescription = err.Error()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
connstr = connstr + dbKey
|
url.Path = "/" + dbKey
|
||||||
|
connstr := url.String()
|
||||||
script = fmt.Sprintf("db = connect('%s');\ncoll = db.getCollection('%s');\n\n%s", connstr, collKey, script)
|
script = fmt.Sprintf("db = connect('%s');\ncoll = db.getCollection('%s');\n\n%s", connstr, collKey, script)
|
||||||
|
|
||||||
if err := os.WriteFile(fname, []byte(script), os.ModePerm); err != nil {
|
if err := os.WriteFile(fname, []byte(script), os.ModePerm); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user