hlxsites / pga-tour-issues

Issue Repository for PGA Tour Sites
0 stars 0 forks source link

feat: more robust link relativizer #24

Closed fkakatie closed 1 year ago

fkakatie commented 1 year ago

Currently, links are made relative if they have a hlx.live, hlx.page, or production domain hostname. This works great on The Players.

The other tournaments, however, have a www.pgatour.com hostname, with a nested pathname indicating the tournament. We should not make all www.pgatour.com links relative, only those that match the hostname and partial pathname.

Using Sentry Tournament of Champions as a test case, where www.pgatour.com is the hostname and /tournaments/sentry-tournament-of-champions/ is the partial pathname:

❌ Examples of links that should NOT be made relative (do not match origin and partial pathname):

✅ Examples of links that SHOULD be changed (match origin and partial pathname):

At a cursory glance, it looks like only articles (currently coming in through the News and Related Stories block feeds) are causing problems, but there may be more throughout the site which is why I think the makeLinksRelative function is a good candidate to solve this problem.