diff --git a/plugins/code-coverage/src/api.ts b/plugins/code-coverage/src/api.ts index f386fa03fe..1443f9de72 100644 --- a/plugins/code-coverage/src/api.ts +++ b/plugins/code-coverage/src/api.ts @@ -76,7 +76,7 @@ export class CodeCoverageRestApi implements CodeCoverageApi { async getCoverageForEntity( entityName: EntityName, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); return (await this.fetch( `/api/code-coverage/report?entity=${entity}`, )) as JsonCodeCoverage; @@ -86,9 +86,11 @@ export class CodeCoverageRestApi implements CodeCoverageApi { entityName: EntityName, filePath: string, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); return await this.fetch( - `/api/code-coverage/file-content?entity=${entity}&path=${filePath}`, + `/api/code-coverage/file-content?entity=${entity}&path=${encodeURI( + filePath, + )}`, ); } @@ -96,11 +98,11 @@ export class CodeCoverageRestApi implements CodeCoverageApi { entityName: EntityName, limit?: number, ): Promise { - const entity = stringifyEntityRef(entityName); + const entity = encodeURI(stringifyEntityRef(entityName)); const hasValidLimit = limit && limit > 0; return (await this.fetch( `/api/code-coverage/history?entity=${entity}${ - hasValidLimit ? `&limit=${limit}` : '' + hasValidLimit ? `&limit=${encodeURI(`${limit}`)}` : '' }`, )) as JsonCoverageHistory; }