mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user