Skip to content

Commit 7d1687c

Browse files
authored
Trim all duplicate slashes (#104)
1 parent bf8e728 commit 7d1687c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,13 @@ collect.set('isCompare', [
5656

5757
export const isDashboard = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(\/|$)/.test(getCleanPathname(url));
5858
collect.set('isDashboard', [
59+
'https://github.com///',
60+
'https://github.com//',
5961
'https://github.com/',
6062
'https://github.com',
6163
'https://github.com/orgs/test/dashboard',
6264
'https://github.com/dashboard/index/2',
65+
'https://github.com//dashboard',
6366
'https://github.com/dashboard',
6467
'https://github.com/orgs/edit/dashboard',
6568
'https://github.big-corp.com/',
@@ -372,6 +375,7 @@ collect.set('isRepoHome', [
372375
'https://github.com/sindresorhus/refined-github/',
373376
'https://github.com/sindresorhus/notifications/',
374377
'https://github.com/sindresorhus/edit',
378+
'https://github.com/sindresorhus///edit',
375379
'https://github.com/sindresorhus/search',
376380
'https://github.com/sindresorhus/branches',
377381
'https://github.com/sindresorhus/refined-github?files=1',
@@ -641,8 +645,8 @@ collect.set('isNewRepoTemplate', [
641645
/** Get the logged-in user’s username */
642646
const getUsername = (): string | undefined => document.querySelector('meta[name="user-login"]')?.getAttribute('content')!;
643647

644-
/** Drop leading and trailing slashes */
645-
const getCleanPathname = (url: URL | HTMLAnchorElement | Location = location): string => url.pathname.slice(1, url.pathname.endsWith('/') ? -1 : undefined);
648+
/** Drop all duplicate slashes */
649+
const getCleanPathname = (url: URL | HTMLAnchorElement | Location = location): string => url.pathname.replace(/\/+/g, '/').slice(1, url.pathname.endsWith('/') ? -1 : undefined);
646650

647651
export interface RepositoryInfo {
648652
owner: string;

0 commit comments

Comments
 (0)