jquense / yup

Dead simple Object schema validation
MIT License
22.72k stars 925 forks source link

URL validation does not accept // #2207

Open c100k opened 4 months ago

c100k commented 4 months ago

Describe the bug

URLs containing "//" are valid according to the spec. See https://github.com/dubzzz/fast-check/pull/4935 for more details.

To Reproduce

const { strictEqual } = require('node:assert');
const { it } = require('node:test');
const { object, string } = require("yup");

it('should pass', async () => {
  const schema = object({
    url: string().url(),
  });

  const obj = {
    url: 'https://mqk2p.pe//',
  };
  const isValid = await schema.isValid(obj);

  strictEqual(isValid, true);
});
node index.test.js

✖ failing tests:

test at index.test.js:5:1
✖ should pass (7.207379ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

  false !== true

      at TestContext.<anonymous> (/Users/toto/index.test.js:15:3)
      at async Test.run (node:internal/test_runner/test:632:9)
      at async startSubtest (node:internal/test_runner/harness:216:3) {
    generatedMessage: true,
    code: 'ERR_ASSERTION',
    actual: false,
    expected: true,
    operator: 'strictEqual'
  }

Expected behavior

This test is expected to pass because "//" is valid in a URL.

Platform: