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

URL's with a fragment or query aren't skipped and give a file not found error #537

Closed
romainmenke opened this issue Jul 21, 2023 · 1 comment · Fixed by #539
Closed

URL's with a fragment or query aren't skipped and give a file not found error #537

romainmenke opened this issue Jul 21, 2023 · 1 comment · Fixed by #539
Labels

Comments

@romainmenke
Copy link
Collaborator

@import "foo.css#bar";
@import "foo.css?bar=baz";

These should be skipped for the same reason that url's with a protocol are skipped.


somewhat related to #536

@romainmenke
Copy link
Collaborator Author

Can be done with :

function isProcessableURL(uri) {
  if (/^(?:[a-z]+:)?\/\//i.test(uri)) {
    return false
  }

  try {
    // needs a base to parse properly
    const url = new URL(uri, "https://example.com")

    if (url.hash) {
      return false
    }

    if (url.search) {
      return false
    }
  } catch {} // Ignore

  return true
}

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

Successfully merging a pull request may close this issue.

2 participants