Skip to content

Joi.string().uri() accepts 'http:/' as valid URL #1994

Closed
@paulmelnikow

Description

@paulmelnikow

Describe the problem you are trying to fix (provide as much context as possible)

I want to reject 'http:/' as an invalid URL

const Joi = require('@hapi/joi')
Joi.validate('http:/', Joi.string().uri())

This does not raise an error. What I expect is:

ValidationError: "value" must be a valid uri

There was a similar report in #1732 for http:// (with two slashes) which was addressed in d7ff4fa. However, that code still accepts http:/ (with one slash).

Which API (or modification of the current API) do you suggest to solve that problem ?

Modify the URI regex generator to reject this case.

Are you ready to work on a pull request if your suggestion is accepted ?

I got as far as writing a test case, though I wasn't sure how to modify the regex generator to solve this.

Metadata

Metadata

Assignees

Labels

bugBug or defect

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions