url.ts
1 /** 2 * Removes the protcol, host and port from a URL, returning 3 * just the path and search portions 4 * 5 * This is useful for taking a URL that points to the production site 6 * and removing anything specific to the location that it is deployed, 7 * creating a partial URL that works both locally or when deployed 8 */ 9 export function stripHost(input: string): string { 10 const url = new URL(input); 11 12 return url.pathname + url.search; 13 }