/* At this point, any content is assumed to be an URL
1763
function(url)  {
					var self = this,
						deferred = $.Deferred();
					/* we are using load so one can specify a target with: url.html #targetelement */
					var $container = $('<div></div>').load(url, function(response, status){
						if ( status !== "error" ) {
							deferred.resolve($container.contents());
						}
						deferred.reject();
					});
					return deferred.promise();
				}
682849
function isUrl (url) {
  if (!url) return false
  url = url.toString()
  return url.indexOf('http://') === 0 || url.indexOf('https://') === 0
}
1340637
function appendUrl(url, urls) {
    var i = urls.length
        found = false;
    while (i--) {
        if (utils.compareUrl(urls[i], url)) 
          found = true; 
    }
    if (found === false && utils.isUrl(url)) 
      urls.push(url);
}
779671
function set(url, content, mimeType) {
			if (url.charAt(0) !== '/') { url = '/'+url; }
			var point = getPoint(url) || new KnownPoint(url);
			// console.info('new url:',url, mimeType);
			point.content = content;
			point.mimeType = mimeType;
    }
135574
function setURLParameter(url, key, value) {
  if(typeof url !== 'string') {
    throw new Error('URLs must be a string');
  }

  if(urlUtils) {
    //node.js
    url = urlUtils.parse(url);

    url.search = ((url.search) ? url.search + '&' : '?') + key + '=' + value;

    url = urlUtils.format(url);
  }
  else {
    //browser
    url = url.split('?');

    url[1] = ((url[1]) ? url[1] + '&' : '') + key + '=' + value;

    url = url.join('?');
  }

  return url;
}
489887
function _cleanURL(url) {
        var index = url.search(/[#\?]/);
        if (index >= 0) {
            url = url.substr(0, index);
        }
        return url;
    }
344639
function(url, cb) {
        var calais = this;

        if (!calais.validateOptions())
            return cb({}, 'Bad options');

        //Make sure we were given a URL.
        if (this._undefinedOrNull(url) || typeof url != 'string' || url.length == 0)
            return cb({}, 'No URL given.');

        //Make sure it's a valid URL.
        if (!(/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url)))
            return cb({}, 'Bad URL');


        request(url, function(error, response, html) {
            if (error)
                return cb({}, error);

            //Limts to just under 100kb....
            html = html.substring(0, 95000);
            
            //We can upload the html directly to Calais if we set the contentType as text/html
            var params = {
                'Host'                   : calais.options.apiHost,
                'x-ag-access-token'      : calais.apiKey,
                'x-calais-language'      : calais.options.language,
                'Content-Type'           : 'text/html',
                'Accept'                 : 'application/json',
                'Content-Length'         : html.length,
                'OutputFormat'           : 'application/json'
            };

            var options = {
                uri    : 'https://' + calais.options.apiHost + calais.options.apiPath,
                method : 'POST',
                body   : html,
                headers: params
            };


            request(options, function(error, response, calaisData) {

                if (error)
                    return cb({}, error);

                if (response === undefined) {
                    return cb({}, 'Undefined Calais response');
                } else if (response.statusCode === 200) {
                    if (!calaisData)
                        return cb({}, calais.errors);

                    try {
                        // parse to a Javascript object if requested
                        var result = JSON.parse(calaisData);
                        result = (typeof result === 'string') ? JSON.parse(result) : result;

                        var parsedResult;
                        if (calais.options.parseData) {
                            parsedResult = calais._parseCalaisData(result, calais.options.minConfidence);
                        } else {
                            parsedResult = result;
                        }

                        return cb(parsedResult, calais.errors);
                    } catch(e) {
                        return cb({}, e);
                    }

                } else
                    return cb({}, 'Request error: ' + (typeof response === 'string' ? response : JSON.stringify(response)));


            });

        });

    }
1177940
function() {
    try {
      var u = new global.URL('b', 'http://a');
      u.pathname = 'c%20d';
      return (u.href === 'http://a/c%20d') && u.searchParams;
    } catch (e) {
      return false;
    }
  }
366592
function resolveURL(url) {
		return new URI(url).absoluteTo(new URI(document.baseURI).search("")).toString();
	}
830822
function urlIsSameOrigin(url) {
  if (typeof document !== 'undefined') {
    // for IE really
    const a = document.createElement('a');
    a.href = url;
    return a.hostname === location.hostname &&
           a.port     === location.port &&
           a.protocol === location.protocol;
  } else {
    const localOrigin = (new URL(location.href)).origin;
    const urlOrigin = (new URL(url, location.href)).origin;
    return urlOrigin === localOrigin;
  }
}
1188080
function parse(url) {
  ['?', '#'].forEach(function(separator) {
    var index = url.indexOf(separator);
    if (index !== -1) url = url.substring(0, index);
  });
  return url;
}
396323
function( url ) {
			var parts = this.path.split('/'),
				other_parts = url.split('/'),
				result = '';
			while ( parts.length > 0 && other_parts.length > 0 && parts[0] == other_parts[0] ) {
				parts.shift();
				other_parts.shift();
			}
			each(other_parts, function(){ result += '../'; })
			return result + parts.join('/');
		}
640084
function resolveUrl(base, url) {
  var value = '';
  if (url.indexOf('://') != -1) {
    // Likely absolute...
    value = url;
  } else {
    // Combine by smashing together and letting the browser figure it out.
    if (url.length && url[0] == '/') {
      // URL is absolute, so strip base to just host.
      var i = url.indexOf('://') + 3;
      i = url.indexOf('/', i);
      if (i != -1) {
        value = base + url;
      } else {
        value = base.substr(0, i) + url;
      }
    } else {
      // URL is relative, so combine with base.
      if (base[base.length] == '/') {
        value = base + '/' + url;
      } else {
        value = base + '/../' + url;
      }
    }
  }
  return value;
}
253607
function (baseURL, params) {

            var encodedArgs = [];

            if (params){

                var key, urlarg;
                var urlize = encodeURIComponent;

                for (key in params){
                    if (params.hasOwnProperty(key)) {
                        urlarg = urlize(key)+'='+urlize(params[key]);
                        encodedArgs.push(urlarg);
                    }
                }
            }

            if (encodedArgs.length > 0){

                if (baseURL.indexOf('?') == -1)
                    return baseURL + '?' + encodedArgs.join('&');
                return baseURL + '&' + encodedArgs.join('&');
            }
            return baseURL;
        }
108919
function contentObjectByUrl( $params )
    {
        $object = false;

        $node = $this->nodeByUrl( $params );
        if( is_object( $node ) )
        {
            $object = $node->object();
        }

        return $object;
    }
1192871
function() {
            var parts = Array.prototype.slice.call(arguments, 0);
            return Urls.normalize(parts.join('/'));
        }
119314
function() {
      var base = getValue(this, 'urlRoot') || getValue(this.collection, 'url') || urlError();
      if (this.isNew()) return base;
      return base + (base.charAt(base.length - 1) == '/' ? '' : '/') + encodeURIComponent(this.id);
    }