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

fix: external URLs normalized to absolute path #14744

Closed

Conversation

daniil4udo
Copy link

Description

This PR addresses the issue of incorrectly handling external URLs within the index.html file. When external URLs are included using the <script> tag, they get merged with the base path, resulting in malformations like /https:// (or prepended with whatever the BASE_URL is).

The changes introduced in this PR ensure that the strings are checked to determine if they are valid URLs before merging, preventing such issues.

Additional context

The problem arose when external script URLs were getting prefixed with the base path, which should not happen. This fix aims to streamline the handling of URLs and prevent potential errors caused by this incorrect merging.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Oct 24, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev
Copy link
Member

In other places, we're checking against excluded cases with a new URL try catch. I think it is better to avoid it here too. See for example:

const isExcludedUrl = (url: string) =>

I think we'll need to check against isExternalUrl, isDataUrl, and if it starts with #.

Would you add a test case for this PR?

@patak-dev patak-dev added feat: html p3-minor-bug An edge case that only affects very specific usage (priority) labels Oct 24, 2023
@daniil4udo
Copy link
Author

As you can see somehow it still resolves to absolute path..

image

@patak-dev
Copy link
Member

I think the fix is correct, just that it is better to align with the way we check for external URLs in other parts of the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: html p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants