halacious icon indicating copy to clipboard operation
halacious copied to clipboard

Params are not set correctly on self links

Open sazzer opened this issue 10 years ago • 1 comments

If the "params" entry is not included on the route configuration then no querystring parameters are included on the self link at all.

If a "params" entry is included on the route configuration then the values are appended but not correctly formatted.

For example, when requesting a URL of '/items?offset=10&pageSize=5&q=item'. A configuration of:

hal: {}

will produce a Self link of '/items'

Whereas a configuration of

hal: {
    query: '{offset,pageSize,q}'
}

will produce a Self link of '/items10,5,item' instead of the URL that I would have expected, which is '/items?offset=10&pageSize=5&q=item'

sazzer avatar Dec 13 '15 21:12 sazzer

Turns out, from having just looked at the code, the problem is more in the documentation than the code. If I use a configuration of:

hal: {
    query: '?offset={offset}&pageSize={pageSize}&q={q}'
}

then it does as I'd expect. It does unfortunately include query parameters that weren't provided on the request though, but gives them empty values.

sazzer avatar Dec 13 '15 21:12 sazzer