diff --git a/src/node/hooks/express/padurlsanitize.js b/src/node/hooks/express/padurlsanitize.js index c4c1b6751..30297479a 100644 --- a/src/node/hooks/express/padurlsanitize.js +++ b/src/node/hooks/express/padurlsanitize.js @@ -1,7 +1,6 @@ 'use strict'; const padManager = require('../../db/PadManager'); -const url = require('url'); exports.expressCreateServer = (hookName, args, cb) => { // redirects browser to the pad's sanitized url if needed. otherwise, renders the html @@ -19,10 +18,7 @@ exports.expressCreateServer = (hookName, args, cb) => { next(); } else { // the pad id was sanitized, so we redirect to the sanitized version - let realURL = sanitizedPadId; - realURL = encodeURIComponent(realURL); - const query = url.parse(req.url).query; - if (query) realURL += `?${query}`; + const realURL = encodeURIComponent(sanitizedPadId) + new URL(req.url).search; res.header('Location', realURL); res.status(302).send(`You should be redirected to ${realURL}`); }