Fix #308 - Allow mDNS addresses (ending with 'local.') during URL validation (#346)

This commit is contained in:
Ronan Jouchet 2017-04-18 17:30:00 -04:00 committed by GitHub
parent a09ae9fe4e
commit f4f74224de
1 changed files with 7 additions and 1 deletions

View File

@ -8,7 +8,13 @@ function normalizeUrl(testUrl) {
if (!parsed.protocol) {
normalized = 'http://' + normalized;
}
if (!validator.isURL(normalized, {require_protocol: true, require_tld: false})) {
const validatorOptions = {
require_protocol: true,
require_tld: false,
allow_trailing_dot: true // mDNS addresses, https://github.com/jiahaog/nativefier/issues/308
};
if (!validator.isURL(normalized, validatorOptions)) {
throw `Your Url: "${normalized}" is invalid!`;
}
return normalized;