MCPcopy Create free account
hub / github.com/dailydotdev/apps / normalizePath

Function normalizePath

packages/shared/src/components/feeds/exploreCategories.ts:21–34  ·  view source on GitHub ↗
(p?: string)

Source from the content-addressed store, hash-verified

19// Strip the query string and (in the extension build, where `webappUrl` is
20// absolute) the host so candidate URLs and `router.asPath` compare uniformly.
21export const normalizePath = (p?: string): string => {
22 let path = p?.split('?')[0] || '';
23 if (/^https?:\/\//.test(path)) {
24 try {
25 path = new URL(path).pathname;
26 } catch {
27 // fall through with the original string
28 }
29 }
30 if (!path || path === '/') {
31 return path;
32 }
33 return path.replace(/\/$/, '');
34};
35
36type Matchable = {
37 id: string;

Callers 1

findActiveChipIdFunction · 0.70

Calls 1

replaceMethod · 0.80

Tested by

no test coverage detected