From f3d918d7e299fa2e4e0608d649eaa34ae55f5f8f Mon Sep 17 00:00:00 2001 From: Ivaylo Novakov Date: Fri, 7 Aug 2020 13:03:32 +0300 Subject: [PATCH] Simplify regex. Remove dead code. --- .gitignore | 1 + handshake-api/index.js | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 43f25aa7..6a4f2eb0 100644 --- a/.gitignore +++ b/.gitignore @@ -78,3 +78,4 @@ docker/data # Cache files __pycache__ /.idea/ +/venv/ diff --git a/handshake-api/index.js b/handshake-api/index.js index 452d50c7..87b5a09a 100644 --- a/handshake-api/index.js +++ b/handshake-api/index.js @@ -20,7 +20,7 @@ const clientOptions = { const client = new NodeClient(clientOptions); // Match both `sia://HASH` and `HASH` links. -const startsWithSkylinkRegExp = /^(sia:\/\/){0,1}[a-zA-Z0-9_-]{46}/; +const startsWithSkylinkRegExp = /^(sia:\/\/)?[a-zA-Z0-9_-]{46}/; const getDomainRecords = async (name) => { const response = await client.execute("getnameresource", [name]); @@ -75,9 +75,6 @@ server.use( proxy("nginx", { // eslint-disable-next-line no-unused-vars userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) { - // if (!userReq.url.endsWith('/')) { - // userRes.redirect(307, `${userReq.url}/`); - // } if (headers.location && headers.location.match(startsWithSkylinkRegExp)) { headers.location = headers.location.replace( startsWithSkylinkRegExp,