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

Cannot validate in Edge as cannot construct resolve URL #407

Open
joe-hilling opened this issue Jan 15, 2025 · 3 comments
Open

Cannot validate in Edge as cannot construct resolve URL #407

joe-hilling opened this issue Jan 15, 2025 · 3 comments

Comments

@joe-hilling
Copy link

Seems to be divergent implementatins of new URL in Edge and Chrome/Firefox

Validator.prototype.validate = function validate (instance, schema, options, ctx) {
  
  var id = schema.$id || schema.id;
  let base = helpers.resolveUrl(options.base,id||'');     # THIS LINE FAILS
  ...

In helpers.resolveUrl the line is

const resolvedUrl = new URL(to, new URL(from, 'resolve://'));

The following statement works in chrome but not Edge (tested in browser console)

new URL('','resolve://')

Fails with error message Failed to construct 'URL': Invalid URL. Seems to be to do with allowed protocols different between browsers.

Tested browsers:

  • Chrome: 131.0.6778.265
  • Edge: 131.0.2903.146
@joe-hilling
Copy link
Author

Related to #405

@kulwinderNZ
Copy link

Did you manage to patch or fix it?

@joe-hilling
Copy link
Author

joe-hilling commented Jan 16, 2025

Did you manage to patch or fix it?

Sorry, switched quickly to ajv as it was breaking some critical deployments and seemed faster to switch implementation. To be honest I would not know where to start!

https://ajv.js.org/guide/getting-started.html

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

No branches or pull requests

2 participants