lagoshny/ngx-hal-client

Resource.getRelationArray does not work properly with templated URLs

Closed this issue · 2 comments

Resource.getRelationArray calls this.getRelationLinkHref(relation) which changes a URL such as

http://host/path/resource?param={value} to

http://host/path/resource?param=

If you then pass

const halOptions: HalOptions = {
  params: [{
    key: 'param',
    value: 'somevalue'
  }]
};

to getRelationArray() you end up with a URL

http://host/path/resource?param=&param=somevalue

I would expect

http://host/path/resource?param=somevalue

Thanks for your issue, I will check it and fix.

Fix it in 1.0.13 version that was already published in npm.

Some notes about templated resource url.
Method this.getRelationLinkHref(relation) awaiting url like this:

http://host/path/resource{?projection,size,sort}

that can be generated by Spring Data Rest.
The method replace part of {?projection,size,sort} to empty string as a result we will have the next url:

http://host/path/resource

Now I added extra logic in Resource.getRelationArray method to clear other url params like this:

http://host/path/resource?param={value}

to

http://host/path/resource

because we will pass HalOptions.params to request.