From 83ddd2330b12a5da7ef70a219b58acdc74ca5b8b Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 18:51:31 -0400 Subject: [PATCH 1/6] Add `isRepoHome` --- index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.ts b/index.ts index be10030a..3a041387 100644 --- a/index.ts +++ b/index.ts @@ -287,6 +287,12 @@ collect.set('isRepoIssueList', [ 'https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc', ]); +export const isRepoHome = (url: URL | Location = location): boolean => getRepoPath(url) === ''; +collect.set('isRepoHome', [ + 'https://github.com/sindresorhus/refined-github', + 'https://github.com/sindresorhus/refined-github/', +]); + export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!); collect.set('isRepoRoot', [ // Some tests are here only as "gotchas" for other tests that may misidentify their pages From 3429ac2f0bebff74a54993c0eb30e22e19488a07 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 18:55:01 -0400 Subject: [PATCH 2/6] Add isRepoRoot() --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 3a041387..82c91718 100644 --- a/index.ts +++ b/index.ts @@ -287,7 +287,7 @@ collect.set('isRepoIssueList', [ 'https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc', ]); -export const isRepoHome = (url: URL | Location = location): boolean => getRepoPath(url) === ''; +export const isRepoHome = (url: URL | Location = location): boolean => isRepoRoot(url) && getRepoPath(url) === ''; collect.set('isRepoHome', [ 'https://github.com/sindresorhus/refined-github', 'https://github.com/sindresorhus/refined-github/', From 2482f93fad44d3b7d524a4c75fc71cce156efb6e Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 19:26:38 -0400 Subject: [PATCH 3/6] Tests --- index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.ts b/index.ts index 82c91718..6709f4ee 100644 --- a/index.ts +++ b/index.ts @@ -289,18 +289,19 @@ collect.set('isRepoIssueList', [ export const isRepoHome = (url: URL | Location = location): boolean => isRepoRoot(url) && getRepoPath(url) === ''; collect.set('isRepoHome', [ + // Some tests are here only as "gotchas" for other tests that may misidentify their pages 'https://github.com/sindresorhus/refined-github', 'https://github.com/sindresorhus/refined-github/', + 'https://github.com/sindresorhus/notifications/', + 'https://github.com/sindresorhus/edit', + 'https://github.com/sindresorhus/search', + 'https://github.com/sindresorhus/branches', ]); export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!); collect.set('isRepoRoot', [ // Some tests are here only as "gotchas" for other tests that may misidentify their pages - 'https://github.com/sindresorhus/edit', - 'https://github.com/sindresorhus/search', - 'https://github.com/sindresorhus/refined-github', - 'https://github.com/sindresorhus/refined-github/', - 'https://github.com/sindresorhus/notifications/', + ...collect.get('isRepoHome') as string[], 'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons', 'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/', 'https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6', @@ -308,7 +309,6 @@ collect.set('isRepoRoot', [ 'https://github.com/sindresorhus/refined-github/tree/57bf4', 'https://github.com/sindresorhus/refined-github?files=1', 'https://github.com/sindresorhus/refined-github/tree/master?files=1', - 'https://github.com/sindresorhus/branches', ]); // This can't use `getRepoPath` to avoid infinite recursion. From a822e00f7a45ec4944c725b9a6a039ed7127b627 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 19:31:17 -0400 Subject: [PATCH 4/6] one more try --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 6709f4ee..eb241013 100644 --- a/index.ts +++ b/index.ts @@ -296,6 +296,7 @@ collect.set('isRepoHome', [ 'https://github.com/sindresorhus/edit', 'https://github.com/sindresorhus/search', 'https://github.com/sindresorhus/branches', + 'https://github.com/sindresorhus/refined-github?files=1', ]); export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!); @@ -307,7 +308,6 @@ collect.set('isRepoRoot', [ 'https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6', 'https://github.com/sindresorhus/refined-github/tree/03fa6b8b4d6e68dea9dc9bee1d197ef5d992fbd6/', 'https://github.com/sindresorhus/refined-github/tree/57bf4', - 'https://github.com/sindresorhus/refined-github?files=1', 'https://github.com/sindresorhus/refined-github/tree/master?files=1', ]); From a959c10eb581b53a588d33e47d7ad8ec7fb2a831 Mon Sep 17 00:00:00 2001 From: Yakov <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 19:37:11 -0400 Subject: [PATCH 5/6] Drop note --- index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/index.ts b/index.ts index eb241013..abd59aff 100644 --- a/index.ts +++ b/index.ts @@ -301,7 +301,6 @@ collect.set('isRepoHome', [ export const isRepoRoot = (url: URL | Location = location): boolean => /^(tree\/[^/]+)?$/.test(getRepoPath(url)!); collect.set('isRepoRoot', [ - // Some tests are here only as "gotchas" for other tests that may misidentify their pages ...collect.get('isRepoHome') as string[], 'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons', 'https://github.com/sindresorhus/refined-github/tree/native-copy-buttons/', From 9e8f82bb70319442a62d4f92ed96cbc36a4e037b Mon Sep 17 00:00:00 2001 From: yakov116 <16872793+yakov116@users.noreply.github.com> Date: Sun, 21 Jun 2020 19:38:13 -0400 Subject: [PATCH 6/6] Update index.ts Co-authored-by: Fregante --- index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.ts b/index.ts index abd59aff..c9e96bbf 100644 --- a/index.ts +++ b/index.ts @@ -287,7 +287,7 @@ collect.set('isRepoIssueList', [ 'https://github.com/sindresorhus/refined-github/issues?q=is%3Aclosed+sort%3Aupdated-desc', ]); -export const isRepoHome = (url: URL | Location = location): boolean => isRepoRoot(url) && getRepoPath(url) === ''; +export const isRepoHome = (url: URL | Location = location): boolean => getRepoPath(url) === ''; collect.set('isRepoHome', [ // Some tests are here only as "gotchas" for other tests that may misidentify their pages 'https://github.com/sindresorhus/refined-github',