Skip to content
Merged
Prev Previous commit
Next Next commit
use native url parser
  • Loading branch information
sreya committed Nov 27, 2024
commit cbc1cfa3ea3808b1489d9cfe29154d9e5182a030
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
"storybook": "pnpm run -C site/ storybook"
},
"devDependencies": {
"@types/url-parse": "^1.4.11",
"prettier": "3.3.3"
},
"dependencies": {
"url-parse": "^1.5.10"
}
}
30 changes: 0 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions site/src/utils/apps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as TypesGen from "api/typesGenerated";
import URLParse from "url-parse";
import { URL } from "url";

export const createAppLinkHref = (
protocol: string,
Expand Down Expand Up @@ -30,10 +30,10 @@ export const createAppLinkHref = (
}

if (appsHost && app.subdomain && app.subdomain_name) {
const url = new URLParse("");
url.set("protocol", protocol);
url.set("hostname", appsHost.replace("*", app.subdomain_name));
url.set("pathname", "/");
const url = new URL("");
url.protocol = protocol;
url.hostname = appsHost.replace("*", app.subdomain_name);
url.pathname = "/";

href = url.toString();
}
Expand Down
8 changes: 4 additions & 4 deletions site/src/utils/portForward.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WorkspaceAgentPortShareProtocol } from "api/typesGenerated";
import URLParse from "url-parse";
import { URL } from "url";

export const portForwardURL = (
host: string,
Expand All @@ -13,9 +13,9 @@ export const portForwardURL = (
const suffix = protocol === "https" ? "s" : "";

const subdomain = `${port}${suffix}--${agentName}--${workspaceName}--${username}`;
const url = new URLParse("");
url.set("protocol", location.protocol);
url.set("hostname", host.replace("*", subdomain));
const url = new URL("");
url.protocol = location.protocol;
url.hostname = host.replace("*", subdomain);

return url.toString();
};
Expand Down
Loading