Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force a single link to an array if requested #8

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

chadkouse
Copy link

fixes #7

forceArray = true;
href.forEach(function(h) {
link = Link(rel, h);
self._links[link.rel] = linkGroupPlus(self._links[link.rel], link, forceArray);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you could do linkGroupPlus(self._links[link.rel], [link]) and get rid of the forceArray. This way you wouldn't even have to change implementation of linkGroupPlus.

@chadkouse
Copy link
Author

Do you think we should handle the case where an array of links with different rels get passed ?

@chadkouse
Copy link
Author

Nevermind - been a long night :) PR coming.

return Link(rel, h)
}) :
Link(rel, arguments[1])
: link;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two ternaries in the same expression are hard to follow.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like var links = (arguments.length === 1) ? link : extractLinks.apply(this, arguments);

and extractLinks would always receive two arguments. A relation and an href (or array of hrefs).

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.

What do you think about allowing the server to force a link to be an array
2 participants