Skip to content

Commit a612a54

Browse files
committed
fix: fix incomplete string escaping
1 parent 45d9274 commit a612a54

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
"storybook": "pnpm run -C site/ storybook"
1010
},
1111
"devDependencies": {
12+
"@types/url-parse": "^1.4.11",
1213
"prettier": "3.3.3"
14+
},
15+
"dependencies": {
16+
"url-parse": "^1.5.10"
1317
}
1418
}

pnpm-lock.yaml

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/pnpm-lock.yaml

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/src/utils/apps.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type * as TypesGen from "api/typesGenerated";
2+
import URLParse from 'url-parse';
23

34
export const createAppLinkHref = (
45
protocol: string,
@@ -16,20 +17,25 @@ export const createAppLinkHref = (
1617

1718
// The backend redirects if the trailing slash isn't included, so we add it
1819
// here to avoid extra roundtrips.
19-
let href = `${preferredPathBase}/@${username}/${workspace.name}.${
20+
let path = `${preferredPathBase}/@${username}/${workspace.name}.${
2021
agent.name
2122
}/apps/${encodeURIComponent(appSlug)}/`;
2223
if (app.command) {
2324
// Terminal links are relative. The terminal page knows how
2425
// to select the correct workspace proxy for the websocket
2526
// connection.
26-
href = `/@${username}/${workspace.name}.${
27+
path = `/@${username}/${workspace.name}.${
2728
agent.name
2829
}/terminal?command=${encodeURIComponent(app.command)}`;
2930
}
3031

3132
if (appsHost && app.subdomain && app.subdomain_name) {
32-
href = `${protocol}//${appsHost}/`.replace("*", app.subdomain_name);
33+
const url = new URLParse('');
34+
url.set('protocol', protocol);
35+
url.set('hostname', appsHost.replace('*', app.subdomain_name));
36+
url.set('pathname', '/');
37+
38+
path = url.toString();
3339
}
34-
return href;
40+
return path;
3541
};

0 commit comments

Comments
 (0)