YunoHost / package_check

Shell script which check package actions: install, remove, upgrade, backup, restore…
GNU General Public License v3.0
21 stars 26 forks source link

Extract base tag href for resolving asset URLs #176

Closed fflorent closed 1 month ago

fflorent commented 1 month ago

Context

My Grist package is marked as broken since package_check has checked the assets.

By taking a closer look, I realized that it wasn't an issue of my package, nor of the upstream app, but of the checker.

Indeed, the browser resolves assets (scripts and stylesheets) paths either from the domain, but also if present using the <base> tag (mdn documentation).

Proposed solution

  1. We extract the base domain
  2. We use urljoin to resolve the asset full url (base can be of the form https://{domain}/path/to/ or a absolute path without the domain like /path/to/).
alexAubin commented 1 month ago

LGTM, cheers also for the urljoin trick :+1:

alexAubin commented 1 month ago

@fflorent : note that I just reverted this PR as it's been breaking the CI for a few days now, in particular because now the tests on "install on subpath" scenario tries to access the app on domain.tld instead of domain.tld/path

This seems related to this unexpected behavior of urljoin :

>>> urljoin("https://foo.tld/path", "/")
'https://foo.tld/'
>>> urljoin("https://foo.tld/path", "")
'https://foo.tld/path'
fflorent commented 1 month ago

@alexAubin Do you have an example of an app which fails, so I can reproduce locally? (if possible, one for which it is quick to run the CI).

alexAubin commented 1 month ago

For example https://github.com/YunoHost-Apps/243-game_ynh