Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: incorrect embedding status, regex security warnings #253

Merged
merged 5 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/repo-query/pages/indexing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions src/utils/urlMatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ export const isGithubRepoPage = (url: string) => {
};

export const isPullRequestCreatePage = (url: string) => {
const githubPullRequestPattern = /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 = /github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files/;
const githubPullRequestFilesChangedPattern = /^https:\/\/(www\.)?github\.com\/[\w.-]+\/[^/]+\/pull\/\d+\/files/;

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");

Expand Down
8 changes: 4 additions & 4 deletions test/utils/urlMatcher.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ 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)
})

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)
})
Expand Down