lint: padurlsanitize.js
parent
86c938cae2
commit
586af5e16e
|
@ -1,7 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const padManager = require('../../db/PadManager');
|
const padManager = require('../../db/PadManager');
|
||||||
const url = require('url');
|
|
||||||
|
|
||||||
exports.expressCreateServer = (hookName, args, cb) => {
|
exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
// redirects browser to the pad's sanitized url if needed. otherwise, renders the html
|
// redirects browser to the pad's sanitized url if needed. otherwise, renders the html
|
||||||
|
@ -19,10 +18,7 @@ exports.expressCreateServer = (hookName, args, cb) => {
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
// the pad id was sanitized, so we redirect to the sanitized version
|
// the pad id was sanitized, so we redirect to the sanitized version
|
||||||
let realURL = sanitizedPadId;
|
const realURL = encodeURIComponent(sanitizedPadId) + new URL(req.url).search;
|
||||||
realURL = encodeURIComponent(realURL);
|
|
||||||
const query = url.parse(req.url).query;
|
|
||||||
if (query) realURL += `?${query}`;
|
|
||||||
res.header('Location', realURL);
|
res.header('Location', realURL);
|
||||||
res.status(302).send(`You should be redirected to <a href="${realURL}">${realURL}</a>`);
|
res.status(302).send(`You should be redirected to <a href="${realURL}">${realURL}</a>`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue