Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract base tag href for resolving asset URLs #176

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

fflorent
Copy link
Contributor

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
Copy link
Member

LGTM, cheers also for the urljoin trick 👍

@alexAubin alexAubin merged commit 58dd90f into YunoHost:master Oct 17, 2024
1 check failed
@fflorent fflorent mentioned this pull request Oct 18, 2024
2 tasks
@alexAubin
Copy link
Member

@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
Copy link
Contributor Author

@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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants