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

follow() should support names and titles #458

Open
mattbishop opened this issue Dec 29, 2022 · 4 comments
Open

follow() should support names and titles #458

mattbishop opened this issue Dec 29, 2022 · 4 comments

Comments

@mattbishop
Copy link

mattbishop commented Dec 29, 2022

Currently it looks like follow(rel, options) only support templated URIs. It would be good to add a way to follow a link by title.

Also, for HAL links, these are useful fields in the spec that could be part of the follow() options:

  • name
  • type
  • profile
  • deprecation
  • hreflang

Here is my workaround, using deprecated methods:

  public async followListEntry(name: string) {
    // NOTE: links() is deprecated in Ketting
    const entryLinks = await this.resource.links("https://level3.rest/patterns/list#list-entry")
    // @ts-ignore
    const entry = entryLinks.find((l) => l.name === name)
    assert(entry !== undefined, `cannot find link named '${name}' in list: ${JSON.stringify(entryLinks)}`)
    this.resource = await this.client.go(entry)
  }
@mattbishop
Copy link
Author

About URL templates, I have an opinion.

@evert
Copy link
Collaborator

evert commented Jan 13, 2023

I would really like a better follow() at some point that has a few more options, but I was already under the impression that the rel is at least always a known key. I understand the purpose of name in HAL, but assumed that if anyone were to use those they would be looking for a rel + a specific named link.

Similar to hreflang, I'd assume people would be looking for a link with a rel and a language.

@mattbishop
Copy link
Author

mattbishop commented Jan 13, 2023

Yes, it's rel + name I am looking for. follow() lets me specify the rel, but I don't see how to add in the name parameter for follow the rel gets me a list of links, so I want to filter by the attributes therein.

@evert
Copy link
Collaborator

evert commented Jan 13, 2023

Yeah that makes sense. Definitely something I'd like. I have some other options I would like to be able to pass to .follow() (completely escapes me what they were), but makes sense to have an options object there.

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

No branches or pull requests

2 participants