Simplify regex. Remove dead code.

This commit is contained in:
Ivaylo Novakov 2020-08-07 13:03:32 +03:00
parent 8ee13bb96c
commit f3d918d7e2
No known key found for this signature in database
GPG Key ID: 06B9354AB08BE9C6
2 changed files with 2 additions and 4 deletions

1
.gitignore vendored
View File

@ -78,3 +78,4 @@ docker/data
# Cache files # Cache files
__pycache__ __pycache__
/.idea/ /.idea/
/venv/

View File

@ -20,7 +20,7 @@ const clientOptions = {
const client = new NodeClient(clientOptions); const client = new NodeClient(clientOptions);
// Match both `sia://HASH` and `HASH` links. // 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 getDomainRecords = async (name) => {
const response = await client.execute("getnameresource", [name]); const response = await client.execute("getnameresource", [name]);
@ -75,9 +75,6 @@ server.use(
proxy("nginx", { proxy("nginx", {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) { userResHeaderDecorator(headers, userReq, userRes, proxyReq, proxyRes) {
// if (!userReq.url.endsWith('/')) {
// userRes.redirect(307, `${userReq.url}/`);
// }
if (headers.location && headers.location.match(startsWithSkylinkRegExp)) { if (headers.location && headers.location.match(startsWithSkylinkRegExp)) {
headers.location = headers.location.replace( headers.location = headers.location.replace(
startsWithSkylinkRegExp, startsWithSkylinkRegExp,