Skip to content

Commit 97d4eef

Browse files
committed
Drop the uri encoding workaround instead of copying its TODO
An earlier commit here made UsageReportDataService skip encoding its uri param, copying the workaround and the TODO that AuthorizationDataService carries: // TODO fix encode the uri parameter in the self link in the backend and set // encodeValue to true afterwards Measured against a DSpace 9.1 backend, that TODO is based on a misreading - there is nothing to fix in the backend. It does not decode the self link; it re-encodes the parameter values minimally, and ':' and '/' are legal in a query component per RFC 3986, so it has no reason to escape them: sent probe=a%25b -> self probe=a%25b (not decoded) sent probe=a%20b -> self probe=a%20b (not decoded) sent probe=a+b -> self probe=a%20b ('+' is a space in form encoding) sent uri=http%3A%2F%2Fx -> self uri=http://x encodeURIComponent on the frontend simply encodes more than it has to. Both urls are valid and denote the same value. Since the comparison now decodes both sides, the encoding no longer matters, so put the param back on the default: encoding is the safer choice for a value that could contain '&' or '#'. Verified in a browser - the home page still logs no self link warning with encoding restored. The same workaround in AuthorizationDataService is left alone: it is upstream code, it works either way, and it is out of scope here.
1 parent a5f19fb commit 97d4eef

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/app/core/statistics/usage-report-data.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ export class UsageReportDataService extends IdentifiableDataService<UsageReport>
4646
searchStatistics(uri: string, page: number, size: number): Observable<UsageReport[]> {
4747
return this.searchBy('object', {
4848
searchParams: [
49-
// TODO fix encode the uri parameter in the self link in the backend and set encodeValue to true afterwards
50-
new RequestParam('uri', uri, false),
49+
new RequestParam('uri', uri),
5150
],
5251
currentPage: page,
5352
elementsPerPage: size,

0 commit comments

Comments
 (0)