Browse Source

publish muk_web_utils - 12.0

pull/35/head
MuK IT GmbH 6 years ago
parent
commit
91f60929e5
  1. 18
      muk_web_utils/static/src/js/core/utils.js

18
muk_web_utils/static/src/js/core/utils.js

@ -26,19 +26,11 @@ var _t = core._t;
var QWeb = core.qweb; var QWeb = core.qweb;
function isUrl(string) { function isUrl(string) {
var protocolAndDomainRE = /^(?:\w+:)?\/\/(\S+)$/;
var localhostDomainRE = /^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/
var nonLocalhostDomainRE = /^[^\s\.]+\.\S{2,}$/;
var match = string.match(protocolAndDomainRE);
if (!match) {
return false;
}
var everythingAfterProtocol = match[1];
if (!everythingAfterProtocol) {
return false;
}
if (localhostDomainRE.test(everythingAfterProtocol) || nonLocalhostDomainRE.test(everythingAfterProtocol)) {
return true;
var protocol = string.match(/^(?:\w+:)?\/\/(\S+)$/);
if (protocol && protocol[1]) {
var localHost = (/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/).test(protocol[1]);
var nonLocalHost = (/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/).test(protocol[1]);
return !!(localHost || nonLocalHost);
} }
return false; return false;
} }

Loading…
Cancel
Save