fix: use url-parse for url construction (#15670)

This fixes some CodeQL-flagged issues. They're not real issues but the
refactor is small and it'll keep the analysis tools quiet.
This commit is contained in:
Jon Ayers
2024-11-27 23:52:11 +02:00
committed by GitHub
parent 40f12aeca3
commit ffb0ebb5b6
5 changed files with 103 additions and 11 deletions
+6 -1
View File
@@ -29,7 +29,12 @@ export const createAppLinkHref = (
}
if (appsHost && app.subdomain && app.subdomain_name) {
href = `${protocol}//${appsHost}/`.replace("*", app.subdomain_name);
const baseUrl = `${protocol}//${appsHost}`;
const url = new URL(baseUrl);
url.hostname = appsHost.replace("*", app.subdomain_name);
url.pathname = "/";
href = url.toString();
}
return href;
};
+6 -1
View File
@@ -12,7 +12,12 @@ export const portForwardURL = (
const suffix = protocol === "https" ? "s" : "";
const subdomain = `${port}${suffix}--${agentName}--${workspaceName}--${username}`;
return `${location.protocol}//${host}`.replace("*", subdomain);
const baseUrl = `${location.protocol}//${host}`;
const url = new URL(baseUrl);
url.hostname = host.replace("*", subdomain);
return url.toString();
};
// openMaybePortForwardedURL tries to open the provided URI through the