Skip to content

Commit

Permalink
Fix fuzzy rule for Youtube thumbnails in JS
Browse files Browse the repository at this point in the history
Add JS tests for fuzzy rules (only youtube thumbnails for now)
  • Loading branch information
benoit74 committed May 30, 2024
1 parent 1cffd0a commit f946842
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions javascript/test/fuzzyRules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import test from 'ava';

import { applyFuzzyRules } from '../src/wombatSetup.js';

test('i.ytimg.com_1', (t) => {
t.is(
applyFuzzyRules(
'i.ytimg.com/vi/-KpLmsAR23I/maxresdefault.jpg?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AH-CYAC0AWKAgwIABABGHIgTyg-MA8=&rs=AOn4CLDr-FmDmP3aCsD84l48ygBmkwHg-g',
),
'i.ytimg.com.fuzzy.replayweb.page/vi/-KpLmsAR23I/thumbnail.jpg',
);
});

test('i.ytimg.com_2', (t) => {
t.is(
applyFuzzyRules(
'i.ytimg.com/vi/-KpLmsAR23I/maxresdefault.png?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AH-CYAC0AWKAgwIABABGHIgTyg-MA8=&rs=AOn4CLDr-FmDmP3aCsD84l48ygBmkwHg-g',
),
'i.ytimg.com.fuzzy.replayweb.page/vi/-KpLmsAR23I/thumbnail.png',
);
});

test('i.ytimg.com_3', (t) => {
t.is(
applyFuzzyRules('i.ytimg.com/vi/-KpLmsAR23I/maxresdefault.jpg'),
'i.ytimg.com.fuzzy.replayweb.page/vi/-KpLmsAR23I/thumbnail.jpg',
);
});

test('i.ytimg.com_4', (t) => {
t.is(
applyFuzzyRules('i.ytimg.com/vi/-KpLmsAR23I/max-res.default.jpg'),
'i.ytimg.com.fuzzy.replayweb.page/vi/-KpLmsAR23I/thumbnail.jpg',
);
});
2 changes: 1 addition & 1 deletion rules/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"replace": "youtube.fuzzy.replayweb.page/\\1\\2"
},
{
"pattern": "i\\.ytimg\\.com\\/vi\\/(.*?)\\/.*?\\.(\\w*?)(?:\\?|$)",
"pattern": "i\\.ytimg\\.com\\/vi\\/(.*?)\\/.*?\\.(\\w*?)(?:\\?.*|$)",
"replace": "i.ytimg.com.fuzzy.replayweb.page/vi/\\1/thumbnail.\\2"
},
{
Expand Down

0 comments on commit f946842

Please sign in to comment.