Skip to content

Commit

Permalink
fuzzy matching rules: more exact rules to fix replay of youtube and v…
Browse files Browse the repository at this point in the history
…imeo content (part of work for webrecorder/browsertrix-crawler#4)

bump version to 2.5.3
  • Loading branch information
ikreymer committed Jan 27, 2021
1 parent cae03c0 commit 9611847
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/sw.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webrecorder/wabac",
"version": "2.5.2",
"version": "2.5.3",
"main": "index.js",
"license": "AGPL-3.0-or-later",
"dependencies": {
Expand Down
7 changes: 4 additions & 3 deletions src/fuzzymatcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ const DEFAULT_RULES =
{
"match": /(twimg.com\/profile_images\/[^/]+\/[^_]+)_([\w]+\.[\w]+)/,
"replace": "$1=_args=$2",
"split": "_"
"splitLast": "_",
"last": true
},
{
"match": /(youtube\.com\/embed\/[^?]+)[?].*/i,
"match": /^https?:\/\/(youtube\.com\/embed\/[^?]+)[?].*/i,
"replace": "$1"
},
{
Expand Down Expand Up @@ -130,7 +131,7 @@ class FuzzyMatcher {;
}

const split = rule && rule.split || "?";
const inx = reqUrl.lastIndexOf(split);
const inx = rule.splitLast ? reqUrl.lastIndexOf(split) : reqUrl.indexOf(split);
const prefix = inx > 0 ? reqUrl.slice(0, inx + split.length) : reqUrl;

return {prefix, rule, fuzzyCanonUrl};
Expand Down

0 comments on commit 9611847

Please sign in to comment.