Skip to content

Commit 681710c

Browse files
authored
Merge pull request #120 from topcoder-platform/fix-challenge-fetch
Fix challenge fetch
2 parents e6732be + cb195d4 commit 681710c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/api/challenges/challenges.service.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
orderBy,
88
uniqBy,
99
} from 'lodash';
10-
import { ConflictException, Injectable } from '@nestjs/common';
10+
import { BadRequestException, ConflictException, Injectable } from '@nestjs/common';
1111
import { isUUID } from 'class-validator';
1212
import { ENV_CONFIG } from 'src/config';
1313
import { Logger } from 'src/shared/global';
@@ -66,9 +66,7 @@ export class ChallengesService {
6666
throw new BadRequestException('Invalid challengeId provided! Uuid expected!');
6767
}
6868

69-
// Use the URL constructor to avoid path traversal/SSRF risks.
70-
const baseUrl = TC_API_BASE.endsWith('/') ? TC_API_BASE.slice(0, -1) : TC_API_BASE;
71-
const requestUrl = new URL(`/challenges/${challengeId}`, baseUrl).toString();
69+
const requestUrl = `${TC_API_BASE}/challenges/${challengeId}`;
7270

7371
try {
7472
const challenge = await this.m2MService.m2mFetch<Challenge>(requestUrl);

0 commit comments

Comments
 (0)