padurlsanitize.js: invert a condition prior to refactoring

Extracted from Ray's work.
This commit is contained in:
muxator 2019-02-09 00:05:21 +01:00
parent d5d28717c4
commit b699621e5a

View file

@ -12,7 +12,10 @@ exports.expressCreateServer = function (hook_name, args, cb) {
} }
padManager.sanitizePadId(padId, function(sanitizedPadId) { padManager.sanitizePadId(padId, function(sanitizedPadId) {
if (sanitizedPadId != padId) { if (sanitizedPadId === padId) {
// the pad id was fine, so just render it
next();
} 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
var real_url = sanitizedPadId; var real_url = sanitizedPadId;
real_url = encodeURIComponent(real_url); real_url = encodeURIComponent(real_url);
@ -20,9 +23,6 @@ exports.expressCreateServer = function (hook_name, args, cb) {
if ( query ) real_url += '?' + query; if ( query ) real_url += '?' + query;
res.header('Location', real_url); res.header('Location', real_url);
res.status(302).send('You should be redirected to <a href="' + real_url + '">' + real_url + '</a>'); res.status(302).send('You should be redirected to <a href="' + real_url + '">' + real_url + '</a>');
} else {
// the pad id was fine, so just render it
next();
} }
}); });
}); });