Skip to content

Commit

Permalink
Modernize the rewriteWebArchiveUrl test helper function
Browse files Browse the repository at this point in the history
This commit changes the code to use a template string and to use `const`
instead of `var`. Combined with the previous commits this allows for
enabling the ESLint `no-var` rule for this file now.
  • Loading branch information
timvandermeij committed Dec 17, 2023
1 parent 0a10a7b commit f9a0d4e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/downloadutils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* eslint-disable no-var */

import crypto from "crypto";
import fs from "fs";
Expand All @@ -25,11 +24,11 @@ function rewriteWebArchiveUrl(url) {
// Web Archive URLs need to be transformed to add `if_` after the ID.
// Without this, an HTML page containing an iframe with the PDF file
// will be served instead (issue 8920).
var webArchiveRegex =
const webArchiveRegex =
/(^https?:\/\/web\.archive\.org\/web\/)(\d+)(\/https?:\/\/.+)/g;
var urlParts = webArchiveRegex.exec(url);
const urlParts = webArchiveRegex.exec(url);
if (urlParts) {
return urlParts[1] + (urlParts[2] + "if_") + urlParts[3];
return `${urlParts[1]}${urlParts[2]}if_${urlParts[3]}`;
}
return url;
}
Expand Down

0 comments on commit f9a0d4e

Please sign in to comment.