ac-bundle-module-utils-url
v0.0.7
Published
utils/url.js: A module bundled by ac-bundle-module.
Downloads
4
Maintainers
Readme
utils/url.js
A module for ac-bundle-app, published by ac-bundle-module.
Available Methods:
encode
function(url, type) {
if (app.has(type) !== true) type = "encode";
var parts = url.split("/");
var str = "";
for (var i=0; i<=parts.length-1; i++) {
if (i > 0) str += "/";
str += type === "encode" ? encodeURIComponent(parts[i]) : decodeURIComponent(parts[i]);
}
return str;
}
decode
function(url) {
console.log(url);
return mod.encode(url, "decode");
}
valid
function(str) {
var pattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
'(\\#[-a-z\\d_]*)?$','i'); // fragment locator
return !!pattern.test(str);
}
Happy Coding!