Closed jevonearth closed 3 years ago
Hi,
We use Joi for this validation, with the following rule: Joi.string().uri()
If Joi refuses your URI, this is because it's not a valid URI, or Joi has a bug (in which case you should report it)
Can you give me a link from a web authority that claims an uri with 2 hashes is a valid uri? I'm not sure it is.
If it's a Joi uri validation bug, you should open an issue to the Joi validation library. Until this is fixed, how can we solve your uri problem without relaxing the validation too much, any idea?
It's unclear to me if using #
is part of the RFC spec. My cursory impression is Joi appears to be dogmatic on that.
The link in question is to a SPA. The #
portions to not get transmitted to a server. The end result here is that the new docusarus validation breaks links that we have had in place for a long time.
Encoding the #
with %23
will not work as a workaround, sadly.
The end result here is that the new docusarus validation breaks links that we have had in place for a long time.
Sorry for that. Also worth considering that before that we didn't do any validation, so you could pass any invalid URL as well. We don't really want to revert these validation logic.
I've opened an issue on Joi because I think if new URL() can parse your URL then Joi should rather accept it (I guess?).
https://github.com/sideway/joi/issues/2435
@anshulrgoyal @teikjun as you are familiar with the validation system, what about adding something like Joi.alternatives(Joi.string().uri(),parseableUrlSchema())
or something, with parseableUrlSchema not rejecting if new URL() is ok?
we can add a Joi.custom()
and check if url.parse
work on the given url or not.
That would be great thanks 👍
As we could use this in other places, please add it to the new package utils-validation
(also worth some tests might be refactored using methods of this package)
🐛 Bug Report
Validation has false positive on URLs with
#
in the URLHave you read the [Contributing Guidelines on issues]
yes
To Reproduce
docusaurus.config.js
as follows:npm run build
Expected behaviour
Build should complete without error
Actual Behavior
We get an error:
Your Environment
"@docusaurus/core": "^2.0.0-alpha.61"