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 Validation - allowRelative ignored when scheme doesn't include "http" #7559

Open
jameswyse opened this issue Sep 30, 2024 · 0 comments
Open

Comments

@jameswyse
Copy link

Describe the bug

The allowRelative option is ignored when http isn't present in the list of schemes

To Reproduce

Define a field as follows:

{
  name: 'url',
  title: 'URL',
  type: 'url',
  validation: Rule => 
    Rule.uri({
      scheme: ['https'],
      allowRelative: true,
    }),
}

Then in that field, enter a relative URL such as /example - this will trigger a validation error of "Does not match allowed protocols/schemes".

The following code works as expected:

{
  name: 'url',
  title: 'URL',
  type: 'url',
  validation: Rule => 
    Rule.uri({
      scheme: ['http', 'https'],
      allowRelative: true,
    }),
}

Expected behavior

This should not cause a validation error.

Screenshots

Screenshot 2024-09-30 at 1 26 25 PM

Which versions of Sanity are you using?

@sanity/cli (global)        3.58.0 (up to date)
@sanity/cli                 3.58.0 (up to date)
@sanity/code-input           4.1.4 (up to date)
@sanity/color-input          4.0.1 (up to date)
@sanity/components          2.14.0 (up to date)
@sanity/dashboard            4.0.0 (up to date)
@sanity/icons                3.4.0 (up to date)
@sanity/production-preview  2.35.3 (up to date)
@sanity/vision              3.58.0 (up to date)
sanity                      3.58.0 (up to date)

What operating system are you using?
macOS 14.6.1 (23G93)

Which versions of Node.js / npm are you running?

  • NPM v10.7.0
  • Node v20.15.1
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

1 participant