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 invalid with htaccess authentication #734

Open
tyjak opened this issue Jan 30, 2024 · 1 comment
Open

URL invalid with htaccess authentication #734

tyjak opened this issue Jan 30, 2024 · 1 comment

Comments

@tyjak
Copy link

tyjak commented Jan 30, 2024

I can't paste url with login and password anymore (since several months now). I've got the "Url invalid" error message.

Exemple of url :

https://login:[email protected]

@Nathan-Roberts123
Copy link

Nathan-Roberts123 commented Feb 4, 2024

I don't know if this was done on purpose or it a mistake but it happens because of line 54 below. In url-regex-safe the urls with HTTP Basic Authentication by default will be invalid, if you want to disable this feature you need to add auth: true as an option when calling urlRegex.

export const createLink = [
body("target")
.exists({ checkNull: true, checkFalsy: true })
.withMessage("Target is missing.")
.isString()
.trim()
.isLength({ min: 1, max: 2040 })
.withMessage("Maximum URL length is 2040.")
.customSanitizer(addProtocol)
.custom(
value =>
urlRegex({ exact: true, strict: false }).test(value) ||
/^(?!https?)(\w+):\/\//.test(value)
)
.withMessage("URL is not valid.")

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