forked from cowboy/jquery-urlinternal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjquery.ba-urlinternal.min.js
9 lines (9 loc) · 1.83 KB
/
jquery.ba-urlinternal.min.js
1
2
3
4
5
6
7
8
9
/*!
* urlInternal - v1.0 - 10/7/2009
* http://benalman.com/projects/jquery-urlinternal-plugin/
*
* Copyright (c) 2009 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
(function($){var h,l=!0,t=!1,n=window.location,m=Array.prototype.slice,c=n.href.match(/^((https?:\/\/.*?\/)?[^#]*)#?.*$/),w=c[1]+"#",u=c[2],e=w.replace(/^https?:(.*)/g,"$1"),i,d,g,s,o,f,v="elemUrlAttr",k="href",r="src",p="urlInternal",j="urlExternal",b="urlFragment",q,z={};function y(B){var A=m.call(arguments,1);return function(){return B.apply(this,A.concat(m.call(arguments)))}}$.isUrlInternal=s=function(A){if(!A||f(A)){return h}if(q.test(A)){return l}if(/^(?:https?:)?\/\//i.test(A)){return t}if(/^[a-z\d.-]+:/i.test(A)){return h}return l};$.isUrlExternal=o=function(B){var A=s(B);return typeof A==="boolean"?!A:A};$.isUrlFragment=f=function(A){var B=(A||"").match(/^([^#]?)([^#]*#).*$/);return !!B&&(B[2]==="#"||A.indexOf(w)===0||(B[0].slice(0,2)==="//"&&A.indexOf(e)===0)||(B[1]==="/"?u+B[2]===w:!/^https?:\/\//i.test(A)&&$('<a href="'+A+'"/>')[0].href.indexOf(w)===0))};function x(B,A){return this.filter(":"+B+(A?"("+A+")":""))}$.fn[p]=y(x,p);$.fn[j]=y(x,j);$.fn[b]=y(x,b);function a(E,D,C,B){var A=B[3]||i()[(D.nodeName||"").toLowerCase()]||"";return A?!!E(D.getAttribute(A)):t}$.expr[":"][p]=y(a,s);$.expr[":"][j]=y(a,o);$.expr[":"][b]=y(a,f);$[v]||($[v]=function(A){return $.extend(z,A)})({a:k,base:k,iframe:r,img:r,input:r,form:"action",link:k,script:r});i=$[v];$.urlInternalHost=d=function(C){C=C?"(?:(?:"+Array.prototype.join.call(arguments,"|")+")\\.)?":"";var A=new RegExp("^"+C+"(.*)","i"),B="^(?:"+n.protocol+")?//"+n.hostname.replace(A,C+"$1").replace(/\\?\./g,"\\.")+(n.port?":"+n.port:"")+"/";return g(B)};$.urlInternalRegExp=g=function(A){if(A){q=typeof A==="string"?new RegExp(A,"i"):A}return q};d("www")})(jQuery);