mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-01 21:26:46 +00:00
Created helper function to replace the authority on a URL
This commit is contained in:
7
src/utils/helpers/uri.ts
Normal file
7
src/utils/helpers/uri.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
export const replaceAuthorityFromUri = (uri: string, newAuthority: string): string => {
|
||||
const [ schema, rest ] = uri.split('://');
|
||||
const [ , ...pathParts ] = rest.split('/');
|
||||
const normalizedPath = pathParts.length ? `/${pathParts.join('/')}` : '';
|
||||
|
||||
return `${schema}://${newAuthority}${normalizedPath}`;
|
||||
};
|
||||
Reference in New Issue
Block a user