Skip to content

Pass the base URL when expanding a templated _links href #1717

Description

@quietbits

CallBuilder._requestFnForLink calls expandUriTemplate(link.href, opts) without its optional third argument, baseUrl. With no base, new URL(expanded, undefined) throws, so every templated link function on a record whose _links are relative fails with TypeError: Invalid URL. The non-templated branch on the next line passes this.url and resolves the same href correctly.

-        uri = new URL(expandUriTemplate(link.href, opts), this.url);
+        uri = new URL(expandUriTemplate(link.href, opts, this.url), this.url);

expandUriTemplate returns an absolute string, so the outer new URL() no longer needs its second argument.

Relative templated hrefs appear in the account-records fixture in test/unit/server/horizon/server.test.ts, but no test calls a link function on one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    • Status
      Backlog (Not Ready)

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions