Skip to content

Commit 861aabf

Browse files
authored
Add isNewRepoTemplate (#71)
1 parent fdd6a4c commit 861aabf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ export const isRepo = (url: URL | HTMLAnchorElement | Location = location): bool
262262
!reservedNames.includes(url.pathname.split('/', 2)[1]!) &&
263263
!isDashboard(url) &&
264264
!isGist(url) &&
265-
!isRepoSearch(url);
265+
!isRepoSearch(url) &&
266+
!isNewRepoTemplate(url);
266267
collect.set('isRepo', [
267268
// Some of these are here simply as "gotchas" to other detections
268269
'https://github.com/sindresorhus/refined-github/blame/master/package.json',
@@ -534,6 +535,12 @@ collect.set('isNewRepo', [
534535
'https://github.com/organizations/npmhub/repositories/new',
535536
]);
536537

538+
// This can't use `getRepo().path` to avoid infinite recursion:
539+
export const isNewRepoTemplate = (url: URL | HTMLAnchorElement | Location = location): boolean => Boolean(url.pathname.split('/')[3] === 'generate');
540+
collect.set('isNewRepoTemplate', [
541+
'https://github.com/fregante/browser-extension-template/generate',
542+
]);
543+
537544
/** Get the logged-in user’s username */
538545
const getUsername = () => document.querySelector('meta[name="user-login"]')!.getAttribute('content')!;
539546

0 commit comments

Comments
 (0)