Skip to content

curies: don't expand when the rel is already absolute (starts with http[s]:) - #98

Closed
joshco wants to merge 1 commit into
codegram:masterfrom
joshco:curie_leave_absolute_alone
Closed

joshco wants to merge 1 commit into
codegram:masterfrom
joshco:curie_leave_absolute_alone

Conversation

@joshco

@joshco joshco commented Mar 12, 2016

Copy link
Copy Markdown

If a rel is already absolute then don't try to help by expanding it.
This change allows folks who are using curies the way hal-browser expects (for doc links) to coexist with hyperclient.
See issue #97

@dblock

dblock commented Mar 12, 2016

Copy link
Copy Markdown
Collaborator

This needs at least tests and a CHANGELOG entry please. I think you might want to use URL.parse or something like that and check for whether a protocol is present, relying on regexes for structured clearly RFC-ed data is always iffy.

@dblock

dblock commented Mar 12, 2016

Copy link
Copy Markdown
Collaborator

Maybe even better, we could combine URIs with URI.join? http://stackoverflow.com/questions/8900782/how-do-i-safely-join-relative-url-segments

@joshco

joshco commented Mar 12, 2016

Copy link
Copy Markdown
Author

Fair point. I was in a jam and needed to make it work. There are better ways to do this. I'll work on that.
While we're at it. How do I tell hyperclient to add url query parameters on the next request?

My use case is that I start navigating at an API entry point, follow some links to collections, then I need to pass a filter as a query string, eg:

GET /api/v1/events?begins_after=20160301

how do I add that query string?
Looking at the hyperclient code, it seems like this can be handled in curies, if the possible query params are defined in the curie. That's not so feasible for me, I want to be able to pass arbitrary query params.

@dblock

dblock commented Mar 13, 2016

Copy link
Copy Markdown
Collaborator

Query parameters are templated links, curies or not, I think it's just straightforward events(begins_after: ...), but I might be misunderstanding the question, open another issue with an example?

@dblock

dblock commented Mar 13, 2016

Copy link
Copy Markdown
Collaborator

In #97 I commended on whether we need this fix at all.

@dblock

dblock commented Mar 14, 2016

Copy link
Copy Markdown
Collaborator

This becomes moot with #101. What should happen here is that the curried link is just like any other link.

@dblock dblock closed this Mar 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants