Skip to content

Commit

Permalink
fix(isMagnetURI): make sure xt= is uri component
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Jun 25, 2022
1 parent c08abad commit 369a79c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/isMagnetURI.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assertString from './util/assertString';

const magnetURIComponent = /xt(?:\.1)?=urn:((?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})($|&)/i;
const magnetURIComponent = /[?&]xt(?:\.1)?=urn:((?:aich|bitprint|btih|ed2k|ed2khash|kzhash|md5|sha1|tree:tiger):[a-z0-9]{32}(?:[a-z0-9]{8})?|btmh:1220[a-z0-9]{64})($|&)/i;

export default function isMagnetURI(url) {
assertString(url);
Expand Down
1 change: 1 addition & 0 deletions test/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -10245,6 +10245,7 @@ describe('Validators', () => {
'magnet:?xt.2=urn:btih:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234',
'magnet:?xt=urn:ed2k:ABCDEFGHIJKLMNOPQRSTUVWXYZ12345678901234567890123456789ABCD',
'magnet:?xt=urn:btmh:1120caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e',
'magnet:?ttxt=urn:btmh:1220caf1e1c30e81cb361b9ee167c4aa64228a7fa4fa9f6105232b28ad099f3a302e',
],
});
/* eslint-enable max-len */
Expand Down

0 comments on commit 369a79c

Please sign in to comment.