parseLinks :: URI -> [TagTree Text] -> [URI]
parseLinks crawlHostURI tt = let
  maybeHostName l = URI.uriRegName <$> URI.uriAuthority l
  setHostName l = l {
      URI.uriAuthority=URI.uriAuthority crawlHostURI
    , URI.uriScheme = URI.uriScheme crawlHostURI}
  getHref = (TS.findTagBranchAttr "href" . TS.content)
  links = mapMaybe getHref $ join $ TS.select linkSelector <$> tt
  relLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      map setHostName $
      mapMaybe URI.parseRelativeReference $
      filter URI.isRelativeReference $
      map unpack links
  absLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      mapMaybe URI.parseAbsoluteURI $
      filter URI.isAbsoluteURI $
      map unpack links
  in (absLinks <> relLinks)
parseLinks :: URI -> [TagTree Text] -> [URI]
parseLinks crawlHostURI tt = let
  maybeHostName l = URI.uriRegName <$> URI.uriAuthority l
  setHostName l = l {
      URI.uriAuthority=URI.uriAuthority crawlHostURI
    , URI.uriScheme = URI.uriScheme crawlHostURI}
  getHref = (TS.findTagBranchAttr "href" . TS.content)
  links = mapMaybe getHref $ join $ TS.select linkSelector <$> tt
  relLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      map setHostName $
      mapMaybe URI.parseRelativeReference $
      filter URI.isRelativeReference $
      map unpack links
  absLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      mapMaybe URI.parseAbsoluteURI $
      filter URI.isAbsoluteURI $
      map unpack links
  in (absLinks <> relLinks)
parseLinks crawlHostURI tt = let
  maybeHostName l = URI.uriRegName <$> URI.uriAuthority l
  setHostName l = l {
      URI.uriAuthority=URI.uriAuthority crawlHostURI
    , URI.uriScheme = URI.uriScheme crawlHostURI}
  getHref = (TS.findTagBranchAttr "href" . TS.content)
  links = mapMaybe getHref $ join $ TS.select linkSelector <$> tt
  relLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      map setHostName $
      mapMaybe URI.parseRelativeReference $
      filter URI.isRelativeReference $
      map unpack links
  absLinks = filter ((==) (maybeHostName crawlHostURI) . maybeHostName) $
      mapMaybe URI.parseAbsoluteURI $
      filter URI.isAbsoluteURI $
      map unpack links
  in (absLinks <> relLinks)