This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit be075016 authored by Michael Breu's avatar Michael Breu
Browse files

Fixing slash encode problems

parent c15c8382
2 merge requests!132Bringing July Release to production,!128Fixing #315 and #319
......@@ -13,7 +13,7 @@ import { Observable } from 'rxjs';
@Injectable({ providedIn: 'root' })
export class ExerciseService {
public resourceUrl = this.applicationConfigService.getEndpointFor('api/exerciseFile/');
public exerciseUrl = this.applicationConfigService.getEndpointFor('api/exercise/');
public exerciseUrl: string = this.applicationConfigService.getEndpointFor('api/exercise/');
constructor(
private http: HttpClient,
......@@ -36,9 +36,18 @@ export class ExerciseService {
}
public loadExercise(exerciseId: string): Observable<SearchResultDTO> {
return this.http.get<SearchResultDTO>(this.exerciseUrl + encodeURIComponent(exerciseId));
return this.http.get<SearchResultDTO>(this.exerciseUrl + this.encodeURIforExerciseId(exerciseId));
}
/*
* behind the apache reverse proxy, encoded slashes are not working.
* I have not found a good way to repair this. So we unencode the slashes here.
*/
private encodeURIforExerciseId(exerciseId: string): string {
const encodedURL = encodeURIComponent(exerciseId);
return encodedURL.replace("%2F", "/").replace("%2f", "/")
}
populateExerciseWithData(exercise: Exercise): Exercise {
if (exercise !== undefined) {
exercise.views = 0;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment