Files
console/e2e/helpers/url.ts

24 lines
642 B
TypeScript

export function getOrganizationIdFromUrl(pathname: string) {
// TODO: use base path from svelte here
const regex = /\/console\/organization-([^/]+)(\/.*)?/;
const match = pathname.match(regex);
if (match) {
return match[1];
}
throw new Error('Organization ID not found in pathname');
}
export function getProjectIdFromUrl(pathname: string) {
// TODO: use base path from svelte here
const regex = /\/console\/project-(?:[a-z]{2,3}-)?([^/]+)(\/.*)?/;
const match = pathname.match(regex);
if (match) {
return match[1];
}
throw new Error('Project ID not found in pathname');
}