thedevs-network / kutt

Free Modern URL Shortener.
https://kutt.it
MIT License
8.2k stars 1.05k forks source link

Cannot create short links with custom domain #665

Open nalves599 opened 1 year ago

nalves599 commented 1 year ago

After upgrading package express-validator from version 6.3.1 -> 6.14.2 at 4e672a8b51e741f0f276fab999d622dc5337ca88, the creation of short links using a custom domain stops working.

This is happening because of this piece of code, which is not having any effect:

req.body.domain = domain || null;

https://github.com/thedevs-network/kutt/blob/develop/server/handlers/validators.ts#L125

Since version 6.5.1 of express-validator, change req.body on custom(...) validator is not possible.

nalves599 commented 1 year ago

Possible fix is change custom(...) to customSanitizer(...) and inside of the sanitizer, instead of set req.body.domain, you should return the new value (e.g. return Promise.resolve(domain); or return Promise.resolve(null);).

diegopatinor commented 4 months ago

Same bug here.