From 5fb6fceb4133ca6770dd4f9ff14cd1183c7c53ba Mon Sep 17 00:00:00 2001 From: Mattias Runge-Broberg Date: Wed, 20 Mar 2024 20:15:43 +0100 Subject: [PATCH] Handle relative swaggerJsonUrl's (#45) --- internal/index.tpl.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/index.tpl.go b/internal/index.tpl.go index f044c19..6b7d7b2 100644 --- a/internal/index.tpl.go +++ b/internal/index.tpl.go @@ -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