Skip to content

Commit

Permalink
Handle relative swaggerJsonUrl's (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasrunge authored Mar 20, 2024
1 parent d5c2e19 commit 5fb6fce
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/index.tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ func IndexTpl(assetsBase, faviconBase string, cfg swgui.Config) string {
var cfg = {{ .ConfigJson }};
var url = cfg.swaggerJsonUrl;
if (!url.startsWith("https://") && !url.startsWith("http://")) {
url = window.location.protocol + "//" + window.location.host + url;
if (url.startsWith(".")) {
var path = window.location.pathname;
path = path.endsWith("/") ? path : path + "/";
url = window.location.protocol + "//" + window.location.host + path + url;
} else {
url = window.location.protocol + "//" + window.location.host + url;
}
}
// Build a system
Expand Down

0 comments on commit 5fb6fce

Please sign in to comment.