Skip to content

Fix missing location error#387

Closed
AlexHolly wants to merge 1 commit into
APIDevTools:mainfrom
SoftBugs:fix-missing-location-error
Closed

Fix missing location error#387
AlexHolly wants to merge 1 commit into
APIDevTools:mainfrom
SoftBugs:fix-missing-location-error

Conversation

@AlexHolly

Copy link
Copy Markdown
Contributor

No description provided.

@coveralls

Copy link
Copy Markdown

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

jonluca commented Jun 6, 2025

Copy link
Copy Markdown
Member

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

@AlexHolly

Copy link
Copy Markdown
Contributor Author

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

@jonluca

jonluca commented Jun 6, 2025

Copy link
Copy Markdown
Member

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
Copy Markdown
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

jonluca commented Jun 6, 2025 via email

Copy link
Copy Markdown
Member

@AlexHolly

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

jonluca commented Jun 6, 2025 via email

Copy link
Copy Markdown
Member

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