mikekelly/hal-browser

links with absolute URLs cause exceptions

joshco opened this issue · 6 comments

Getting Chrome error:

Uncaught Error: URNs do not have any generally defined hierarchical components

hal.js:27   var norm = uri.absoluteTo(cur);

When retrieving my API entry point:

{
  "motd": "Welcome to the API Endpoint!",
  "_links": {
    "osdi:people": {
      "href": "http://demo.osdi.io/api/v1/people",
      "title": "The collection of people in the system"
    },
   .....
}

hmm. maybe this is a curie problem...

More info, looks like it is the curies, or more specifically the key names being seen as URNs, ie 'osdi:people'.
When no curie definition is present, then the hal browser will suffer a js exception and fail to render the page.
In my local branch, for now I'm try/catching that method call and writing a note to console if it can't normalize a rel.

https://github.com/opensupporter/hal-browser/blob/93884b7a9d8d81ee6c41c9d65a254e64289b7fa7/js/hal.js#L28-L33

I propose (beg?) that HAL browser be more liberal in what it accepts. Many people will use HAL browser as they are learning how to build a HAL API, and if it is too strict, they will never be able to figure out how to emit a valid document.

👍

2fde261#diff-e684a8343f8a30c1d37d8bc45f73423a intro'd it, and i think it was a regression

same as #62

Believe PR #81 will fix this.

i can confirm PR 81 fixed this