linkWithHref method

Link? linkWithHref(
  1. String href
)

Finds the first Link with the given HREF in the publication's links.

Searches through (in order) readingOrder, resources and links recursively following alternate and children links.

If there's no match, try again after removing any query parameter and anchor from the given href.

Implementation

Link? linkWithHref(String href) {
  Link? find(String href) =>
      readingOrder.deepLinkWithHref(href) ??
      resources.deepLinkWithHref(href) ??
      links.deepLinkWithHref(href);

  return find(href) ?? find(href.takeWhile((it) => !"#?".contains(it)));
}