From e5dff8a4f323a75f5af60000d7783bb230a1be49 Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 11 Aug 2023 12:36:37 +0530 Subject: [PATCH 1/5] fix: incorrect embedding status --- src/repo-query/pages/indexing.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/repo-query/pages/indexing.tsx b/src/repo-query/pages/indexing.tsx index 6580b9e2..e53e96ed 100644 --- a/src/repo-query/pages/indexing.tsx +++ b/src/repo-query/pages/indexing.tsx @@ -86,7 +86,7 @@ export const IndexingPage = ({ ownerName, repoName, setCurrentPage }: { ownerNam return; } - const reader = response.body?.getReader(); + const reader = embedResponse.body?.getReader(); if (reader) { const decoder = new TextDecoder("utf-8"); From 36307a9b5d75d9ebf174f3d13122ba5ccf35915a Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 11 Aug 2023 12:45:29 +0530 Subject: [PATCH 2/5] chore: isOnGithub with new URL() --- src/utils/urlMatchers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/urlMatchers.ts b/src/utils/urlMatchers.ts index 56e0f880..ad88af87 100644 --- a/src/utils/urlMatchers.ts +++ b/src/utils/urlMatchers.ts @@ -50,7 +50,7 @@ export const isPullRequestFilesChangedPage = (url: string) => { return githubPullRequestFilesChangedPattern.test(url); }; -export const isOnGitHub = (url: string) => url.includes("github.com"); +export const isOnGitHub = (url: string) => new URL(url).hostname === "github.com"; export const getRepoAPIURL = (url: string) => url.replace(/github\.com/, "api.github.com/repos"); From cb794d9f87aed46a335dbc5eaaa3f931796c6a09 Mon Sep 17 00:00:00 2001 From: Anush Date: Fri, 11 Aug 2023 13:00:21 +0530 Subject: [PATCH 3/5] chore: files changed page URL with ^ & $ --- src/utils/urlMatchers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/urlMatchers.ts b/src/utils/urlMatchers.ts index ad88af87..124789d0 100644 --- a/src/utils/urlMatchers.ts +++ b/src/utils/urlMatchers.ts @@ -45,7 +45,7 @@ export const isPullRequestCreatePage = (url: string) => { }; export const isPullRequestFilesChangedPage = (url: string) => { - const githubPullRequestFilesChangedPattern = /github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files/; + const githubPullRequestFilesChangedPattern = /^https:\/\/github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files$/; return githubPullRequestFilesChangedPattern.test(url); }; From 9502fece59926382ae037a77b486d93d0012c79d Mon Sep 17 00:00:00 2001 From: Anush008 Date: Fri, 11 Aug 2023 13:09:22 +0530 Subject: [PATCH 4/5] chore: PR page pattern update --- src/utils/urlMatchers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/urlMatchers.ts b/src/utils/urlMatchers.ts index 124789d0..bc00ce79 100644 --- a/src/utils/urlMatchers.ts +++ b/src/utils/urlMatchers.ts @@ -39,7 +39,7 @@ export const isGithubRepoPage = (url: string) => { }; export const isPullRequestCreatePage = (url: string) => { - const githubPullRequestPattern = /github\.com\/[\w.-]+\/[^/]+\/compare\/\w+/; + const githubPullRequestPattern = /^https:\/\/github\.com\/[\w.-]+\/[^/]+\/compare\/\w+$/; return githubPullRequestPattern.test(url); }; From eb7c6e44e9cafcf23af6cba9615c1b5698907121 Mon Sep 17 00:00:00 2001 From: Anush008 Date: Fri, 11 Aug 2023 13:25:25 +0530 Subject: [PATCH 5/5] chore: Update tests with new matchers --- src/utils/urlMatchers.ts | 4 ++-- test/utils/urlMatcher.test.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/urlMatchers.ts b/src/utils/urlMatchers.ts index bc00ce79..9db5b140 100644 --- a/src/utils/urlMatchers.ts +++ b/src/utils/urlMatchers.ts @@ -39,13 +39,13 @@ export const isGithubRepoPage = (url: string) => { }; export const isPullRequestCreatePage = (url: string) => { - const githubPullRequestPattern = /^https:\/\/github\.com\/[\w.-]+\/[^/]+\/compare\/\w+$/; + const githubPullRequestPattern = /^https:\/\/(www\.)?github\.com\/[\w.-]+\/[^/]+\/compare\/\w+/; return githubPullRequestPattern.test(url); }; export const isPullRequestFilesChangedPage = (url: string) => { - const githubPullRequestFilesChangedPattern = /^https:\/\/github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files$/; + const githubPullRequestFilesChangedPattern = /^https:\/\/(www\.)?github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files/; return githubPullRequestFilesChangedPattern.test(url); }; diff --git a/test/utils/urlMatcher.test.ts b/test/utils/urlMatcher.test.ts index a596ee69..06076875 100644 --- a/test/utils/urlMatcher.test.ts +++ b/test/utils/urlMatcher.test.ts @@ -79,8 +79,8 @@ test('isPullRequestCreatePage', () => { expect(isPullRequestCreatePage('https://github.com/username/repo/compare/')).toBe(false) expect(isPullRequestCreatePage('https://github.com/username/repo/compare/https://google.com/')).toBe(true) expect(isPullRequestCreatePage('https://github.com/username/repo/compare/https://google.com//')).toBe(true) - expect(isPullRequestCreatePage('www.github.com/username/repo/compare/https://google.com//')).toBe(true) - expect(isPullRequestCreatePage('github.com/username/repo/compare/https://google.com//')).toBe(true) + expect(isPullRequestCreatePage('www.github.com/username/repo/compare/https://google.com//')).toBe(false) + expect(isPullRequestCreatePage('github.com/username/repo/compare/https://google.com//')).toBe(false) expect(isPullRequestCreatePage('https://google.com/')).toBe(false) }) @@ -88,8 +88,8 @@ test('isPullRequestFilesChangedPage', () => { expect(isPullRequestFilesChangedPage('https://www.github.com/')).toBe(false) expect(isPullRequestFilesChangedPage('https://github.com/username/repo/pull/123/files')).toBe(true) expect(isPullRequestFilesChangedPage('https://github.com/username/repo/pull/123/files/')).toBe(true) - expect(isPullRequestFilesChangedPage('www.github.com/username/repo/pull/123/files')).toBe(true) - expect(isPullRequestFilesChangedPage('github.com/username/repo/pull/123/files/')).toBe(true) + expect(isPullRequestFilesChangedPage('www.github.com/username/repo/pull/123/files')).toBe(false) + expect(isPullRequestFilesChangedPage('github.com/username/repo/pull/123/files/')).toBe(false) expect(isPullRequestFilesChangedPage('github.com/username/repo/pull/123/fil')).toBe(false) expect(isPullRequestFilesChangedPage('https://google.com/')).toBe(false) })