Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Adjust URL regex to avoid false positives
Browse files Browse the repository at this point in the history
Fixes #83
  • Loading branch information
arkon committed Apr 1, 2023
1 parent 71a3935 commit 6c75d8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

34 changes: 29 additions & 5 deletions src/util/urls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@ import { cleanUrl, urlsFromIssueBody } from './urls';

describe('urlsFromIssueBody', () => {
it('extracts URLs', () => {
([['foo https://mangadex.org bar', ['mangadex.org']]] as const).forEach(
([body, expectedUrls]) => {
expect(urlsFromIssueBody(body)).toStrictEqual(expectedUrls);
},
);
(
[
['foo https://mangadex.org bar', ['mangadex.org']],
[
`### Source information and language
Sunshine Butterfly Scans 1.4.29 (English)
### Source new URL
wings.sbs
### Other details
I have searched for previous issues about the matter of Sunshine Butterfly's changed domain. I checked the version of the last issue raised, and it is quite old. I saw that the current extension has been updated, but the domain remains unchanged.
### Acknowledgements
- [X] I have searched the existing issues and this is a new ticket, **NOT** a duplicate or related to another open or closed issue.
- [X] I have written a short but informative title.
- [X] I have updated all installed extensions.
- [X] I have checked if the source URL is not already updated by opening WebView.
- [X] I will fill out all of the requested information in this form.`,
['wings.sbs'],
],
] as const
).forEach(([body, expectedUrls]) => {
expect(urlsFromIssueBody(body)).toStrictEqual(expectedUrls);
});
});

it('excludes some URLs', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/util/urls.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const URL_REGEX = /(https?:\/\/)?([\w\-]+\.)+[\w\-]{2,}/gi;
const URL_REGEX = /(https?:\/\/)?([\w\-]+\.)+[A-Za-z]{2,14}/gi;
const EXCLUSION_LIST = [
'tachiyomi.org',
'github.com',
Expand Down

0 comments on commit 6c75d8d

Please sign in to comment.