From bce557cc2dc767628bed6aac87301a1be7c5431b Mon Sep 17 00:00:00 2001 From: rxliuli Date: Tue, 4 Nov 2025 05:03:50 +0800 Subject: init commit --- src/utils/url.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/utils/url.ts (limited to 'src/utils/url.ts') diff --git a/src/utils/url.ts b/src/utils/url.ts new file mode 100644 index 0000000..8596d89 --- /dev/null +++ b/src/utils/url.ts @@ -0,0 +1,13 @@ +/** + * Removes the protcol, host and port from a URL, returning + * just the path and search portions + * + * This is useful for taking a URL that points to the production site + * and removing anything specific to the location that it is deployed, + * creating a partial URL that works both locally or when deployed + */ +export function stripHost(input: string): string { + const url = new URL(input); + + return url.pathname + url.search; +} -- cgit v1.2.3