Skip to content

Conversation

@kkartunov
Copy link
Collaborator

@kkartunov kkartunov requested a review from jmgasper as a code owner December 17, 2025 08:40
@kkartunov kkartunov requested a review from vas3a December 17, 2025 08:40
if (!auth.tokenV3) {
const utmSource = communityId || 'community-app-main';
window.location.href = `${config.URL.AUTH}/member?retUrl=${encodeURIComponent(`${window.location.origin}${window.location.pathname}`)}&utm_source=${utmSource}&regSource=challenges`;
window.location.href = appendUtmParamsToUrl(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ security]
The appendUtmParamsToUrl function is used to construct a URL with query parameters. Ensure that this function properly encodes all URL components to prevent potential security issues such as URL injection.


// handle values that might contain '='
const cookieValue = decodeURIComponent(cookieStr.split('=').slice(1).join('='));
return JSON.parse(cookieValue);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider logging the error or handling it in a way that provides more context. Swallowing errors silently can make debugging difficult.


return urlObj.toString();
} catch (error) {
return url;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ maintainability]
Consider logging the error or handling it in a way that provides more context. Swallowing errors silently can make debugging difficult.

* @param url - The base URL to append parameters to
* @returns URL with UTM parameters appended, or original URL if no cookie exists
*/
export function appendUtmParamsToUrl(url, defaultParams = {}) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
The function appendUtmParamsToUrl should validate the url parameter more robustly. Currently, it only checks for falsy values, but malformed URLs could still cause issues.

@vas3a
Copy link
Collaborator

vas3a commented Dec 17, 2025

@kkartunov let's close this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants