Skip to content

Conversation

@vas3a
Copy link
Collaborator

@vas3a vas3a commented Oct 29, 2025

Reversing previous work to url builder because using url constructor with base url will strip out any url paths from the base url.

@vas3a vas3a requested a review from kkartunov October 29, 2025 11:19
// Use the URL constructor to avoid path traversal/SSRF risks.
const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE;
const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString();
const requestUrl = `${TC_API_BASE}/challenges/${challengeId}`;

Choose a reason for hiding this comment

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

[⚠️ correctness]
Using string concatenation for URL construction can lead to issues such as double slashes or missing slashes, especially if TC_API_BASE ends with a slash. Consider using a more robust method to ensure the URL is constructed correctly, such as checking for trailing slashes or using a library designed for URL manipulation.

@kkartunov kkartunov merged commit 681710c into dev Oct 29, 2025
6 checks passed
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.

3 participants