From f9a0d4efe8290dcb857d87f0888044041200d027 Mon Sep 17 00:00:00 2001 From: Tim van der Meij Date: Sun, 17 Dec 2023 20:37:58 +0100 Subject: [PATCH] Modernize the `rewriteWebArchiveUrl` test helper function 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. --- test/downloadutils.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/downloadutils.mjs b/test/downloadutils.mjs index f14cadb90..682e916e3 100644 --- a/test/downloadutils.mjs +++ b/test/downloadutils.mjs @@ -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"; @@ -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; }