Skip to content

Commit 5fb6fce

Browse files
authored
Handle relative swaggerJsonUrl's (#45)
1 parent d5c2e19 commit 5fb6fce

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/index.tpl.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ func IndexTpl(assetsBase, faviconBase string, cfg swgui.Config) string {
9595
var cfg = {{ .ConfigJson }};
9696
var url = cfg.swaggerJsonUrl;
9797
if (!url.startsWith("https://") && !url.startsWith("http://")) {
98-
url = window.location.protocol + "//" + window.location.host + url;
98+
if (url.startsWith(".")) {
99+
var path = window.location.pathname;
100+
path = path.endsWith("/") ? path : path + "/";
101+
url = window.location.protocol + "//" + window.location.host + path + url;
102+
} else {
103+
url = window.location.protocol + "//" + window.location.host + url;
104+
}
99105
}
100106
101107
// Build a system

0 commit comments

Comments
 (0)