bleupen / halacious

a better HAL processor for Hapi
MIT License
108 stars 22 forks source link

Params are not set correctly on self links #81

Open sazzer opened 8 years ago

sazzer commented 8 years ago

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 commented 8 years ago

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.