Skip to content

Fix missing location error #387

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

Closed

Conversation

AlexHolly
Copy link
Contributor

No description provided.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 15479477412

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 91.565%

Totals Coverage Status
Change from base Build 15425489077: -0.3%
Covered Lines: 1659
Relevant Lines: 1786

💛 - Coveralls

@jonluca
Copy link
Collaborator

jonluca commented Jun 6, 2025

When would window be defined but window.location doesn't exist?

@AlexHolly
Copy link
Contributor Author

I use jsdom in my unit tests. This is probably why it fails there.

@jonluca
Copy link
Collaborator

jonluca commented Jun 6, 2025

Ok let me think about the best way to do this. I'll add a fix later today, will close this for now.

@jonluca jonluca closed this Jun 6, 2025
@AlexHolly
Copy link
Contributor Author

@jonluca

Hi, thanks for the quick response!

I tested the fix, but it's still not working in my case. The check should be:

&& typeof location !== "undefined"

Using just location to check for undefined won't work reliably here, and window.location is also not available in my environment.

Error:

ReferenceError: location is not defined
    at Object.cwd (project\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\util\url.js:93:42)

@jonluca
Copy link
Collaborator

jonluca commented Jun 6, 2025 via email

@AlexHolly
Copy link
Contributor Author

One more error in case window.location.href == 'about:blank'

Adding && window.location.href !== 'about:blank' solves the issue

TypeError: Invalid URL
    at new URL (node:internal/url:818:25)
    at Object.resolve (project\node_modules\@apidevtools\json-schema-ref-parser\dist\lib\util\url.js:78:25)

@jonluca
Copy link
Collaborator

jonluca commented Jun 6, 2025 via email

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.

3 participants