Skip to content

Commit 2ea4f5e

Browse files
authored
Tracking domain check + Endpoints sanitize array tweaks (#1675)
* Tracking + Endpoints sanitize array tweaks * Cleanup * Decode endpoints URL
1 parent f54dbcf commit 2ea4f5e

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/app/(sidebar)/endpoints/components/EndpointsJsonResponse.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,20 @@ export const EndpointsJsonResponse = ({
7777
return {};
7878
}
7979

80-
const url = new URL(val);
81-
82-
const paths = sanitizeArray(url.pathname.split("/")).map((pn) => {
83-
// Remove { "%7B" character
84-
return pn.replace("%7B", "");
85-
});
86-
87-
return { paths, searchParams: url.searchParams };
80+
try {
81+
const decodedUrl = decodeURIComponent(val);
82+
const url = new URL(decodedUrl);
83+
84+
const paths = sanitizeArray(url.pathname.split("/")).map((pn) => {
85+
// Remove { "%7B" and } "%7D" characters
86+
return pn.replaceAll("%7B", "").replaceAll("%7D", "");
87+
});
88+
89+
return { paths, searchParams: url.searchParams };
90+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
91+
} catch (e) {
92+
return {};
93+
}
8894
};
8995

9096
const handleLinkHref = (val: string) => {

src/metrics/tracking.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export const initTracking = () => {
2020

2121
const { hostname } = window.location;
2222

23-
if (hostname === "lab.stellar.org") {
23+
if (["lab.stellar.org"].includes(hostname)) {
2424
apiKey = AMPLITUDE_API_KEY_PROD;
25-
} else if (hostname.includes("previews.kube001.services.stellar-ops.com")) {
25+
} else if (hostname.endsWith(".previews.kube001.services.stellar-ops.com")) {
2626
apiKey = AMPLITUDE_API_KEY_DEV;
2727
}
2828

0 commit comments

Comments
 (0)