JavaScript is url()

1 개요[ | ]

JavaScript is_url()
function is_url(url) {
    return ( null != url.match(/(http|https|ftp):\/\/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g) );
}

console.log( "== true ==");
console.log( is_url("ftp://foo.bar.com/") );
console.log( is_url("http://foo.bar.com/") );
console.log( is_url("https://foo.bar.com/") );
console.log( is_url("http://zetawiki.com/wiki/%ED%95%A8%EC%88%98_is_url()") );
console.log( is_url("http://zetawiki.com/wiki/함수_is_url()") );

console.log( "== false ==");
console.log( is_url("foo.bar.com") );
console.log( is_url("ldap://foo.bar.com/") );
console.log( is_url("ldap://[2001:db8::7]/c=GB?objectClass?one") );
console.log( is_url("telnet://192.0.2.16:80/") );

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}