mikekelly / hal-browser

An API browser for the hal+json media type
MIT License
835 stars 157 forks source link

links with absolute URLs cause exceptions #79

Open joshco opened 8 years ago

joshco commented 8 years ago

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"
    },
   .....
}
joshco commented 8 years ago

hmm. maybe this is a curie problem...

joshco commented 8 years ago

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.

drdamour commented 8 years ago

:+1:

https://github.com/mikekelly/hal-browser/commit/2fde261922a68ca922648f09d364323ac4f1e970#diff-e684a8343f8a30c1d37d8bc45f73423a intro'd it, and i think it was a regression

drdamour commented 8 years ago

same as #62

billyyarosh commented 8 years ago

Believe PR #81 will fix this.

drdamour commented 8 years ago

i can confirm PR 81 fixed this