Skip to content

Commit

Permalink
fix tests and edgecases
Browse files Browse the repository at this point in the history
  • Loading branch information
alweber-cap committed Jan 30, 2025
1 parent 115152d commit b720c6d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const {
FEATURE_EXTENSIONS_ENABLED,
SHOW_VERSION,
SW_ENABLED,
HOST,
HOST = 'http://localhost',
PORT = '3100',
FEATURE_ENTERTHECLOUD,
FEATURE_JWT_EXTENDED_TIMEOUT_ENABLED,
Expand Down
6 changes: 3 additions & 3 deletions helpers/redirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const global = require('../config/global');
* @param {string} redirectUrl URL to which the user should be redirected
* @returns {string} URL without multiple leading slashes
*/
const collapseLeadingSlashes = (redirectUrl) => redirectUrl.replace(/^\/*/, '/');
const collapseLeadingSlashes = (redirectUrl) => redirectUrl.replace(/^\/+/, '/');

/**
* Transform given URL to valid (sanitized and relative) redirect URL
Expand All @@ -17,12 +17,12 @@ const getValidRedirect = (redirectUrl) => {
if (!redirectUrl) return '/';
const sanitizedUrl = sanitizeHtml(redirectUrl);
let relativeUrl = '/';
const parsedUrl = URL.parse(sanitizedUrl, global.HOST);
const parsedUrl = URL.parse(collapseLeadingSlashes(sanitizedUrl), global.HOST);
if (parsedUrl) {
relativeUrl = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;
}

return collapseLeadingSlashes(relativeUrl);
return relativeUrl;
};

const joinPathWithQuery = (path, paramsString) => (paramsString ? `${path}?${paramsString}` : path);
Expand Down

0 comments on commit b720c6d

Please sign in to comment.