Skip to content

Function: rewriteCanonicalKeyUrl() ​

rewriteCanonicalKeyUrl(url, serviceRoot, isEntitySet): string | undefined

Defined in: utils/canonical-key-url.ts:15

Map the canonical URL of an entity, {serviceRoot}/{EntitySet}({key}) (OData-URL 4.01 §4.3.1), to the key-as-segment form {serviceRoot}/{EntitySet}/{key} that the OData route decorators (@ODataGetByKey, @ODataPatch, @ODataPut, @ODataDelete) are registered on.

Nest joins a controller path and a method path with /, so a route cannot be declared as Products(:key); ODataModule rewrites the request URL before routing instead. The key text is kept as sent (still percent-encoded), so @Param('key') receives the same value for both forms: 1, 'abc', orderId=1,itemId=2. Path segments after the key and the query string are kept.

Only the segment right after the service root is rewritten, and only when its name is an entity set (isEntitySet). Returns undefined when the URL is not such a canonical URL.

Parameters ​

url ​

string

serviceRoot ​

string

isEntitySet ​

(name) => boolean

Returns ​

string | undefined