获取当前URL

@return {string}
494595
function getLocation() {
    // Firefox下`location.hash`存在自动解码的情况，
    // 比如hash的值是**abc%3def**，
    // 在Firefox下获取会成为**abc=def**
    // 为了避免这一情况，需要从`location.href`中分解
    let index = location.href.indexOf('#');
    let url = index < 0 ? '/' : (location.href.slice(index + 1) || '/');

    return url;
}
432933
function ensureUrl (v) {
  if (typeof v === 'string') {
    return url.parse(v)
  } else if (v instanceof url.Url) {
    return v
  } else if (url.URL && v instanceof url.URL) { // check for url.URL because it wasn't added until Node.js 6.13.0
    return url.parse(v.toString())
  } else {
    return v
  }
}
628906
function getPageUrl(pageUrl, isDev, urlQueryOpts = {}) {
    const urlParseResult = urlParse(pageUrl);

    const protocol = isDev ? 'http:' : 'https:';

    // 开发场景和生产环境的地址不一样
    if (isDev) {
        urlQueryOpts.now_n_http = 1;
        urlQueryOpts.no_eruda = 1;
        urlQueryOpts.no_logger = 1;
    } else {
        urlQueryOpts._bid = 3170;
    }

    // TODO query 应该和 urlQueryOpts 合并
    return urlHandle.getUrl(`${protocol}//${urlParseResult.host}${urlParseResult.pathname}${urlParseResult.query}`, urlQueryOpts);
}
385780
function parseURL(s) {
  var url = null;
  try {
    url = new URL(s);
  } catch (error) {
    console.error(error);
  }
  return url;
}
1020963
function getPath(url, root) {
    var ret = url;
    var tmp;
    var _2;
    var alias = _.alias;
    var id;
    root = root || defaultConfig.baseURL;
    root = root.substr(0, root.lastIndexOf('/'));
    id = url; //模块id

    if (regAlias.test(url) && alias[url]) {
        ret = alias[url];

    } else if (/^(\w+)(\d)?:.*/.test(url)) { //如果用户路径包含协议
        ret = url;
    } else {
        tmp = url.charAt(0);
        _2 = url.slice(0, 2);

        if (tmp !== '.' && tmp !== '/') { //相对于根路径
            ret = root + '/' + url;
        } else if (_2 === './') { //相对于兄弟路径
            id = url.substr(2);
            ret = root + '/' + id;
        } else if (_2 === '..') { //相对于父路径
            // var arr = root.replace(/\/$/, '').split('/');
            var arr = root.split('/');
            tmp = url.replace(/\.\.\//g, function() {
                arr.pop();
                return '';
            });
            id = tmp;
            ret = arr.join('/') + '/' + tmp;
        }
    }

    var ext = 'js'; //默认是js文件
    tmp = ret.replace(/[?#].*/, '');
    if (/\.(\w+)$/.test(tmp)) {
        ext = RegExp.$1;
    }
    if (ext !== 'css' && tmp === ret && !regIsJS.test(ret)) { //如果没有后缀名会补上.js
        ret += '.js';
    }
    return [ret, ext, id];
}
935840
public function getScriptUrl()
    {
        if (!$this->scriptUrl) {
            $scriptName = 'index.php';
            if(false != $scriptUrl = $this->getServer('PHP_SELF')) {
                $scriptName = $this->getServer('SCRIPT_FILENAME');
                // 去掉 index.php之后的字符
                if (false !== ($pos = stripos($scriptUrl, basename($scriptName)))) {
                    $scriptUrl = substr($scriptUrl, 0, $pos + strlen(basename($scriptName)));
                }
                
                if($scriptName && $scriptName == $scriptUrl) {
                    $docRoot = $this->getServer('DOCUMENT_ROOT');
                    if($docRoot && strpos($scriptName, $docRoot) === 0) {
                        $scriptUrl = str_replace('\\','/', str_replace($docRoot, '', $scriptName));
                    } else {
                        $scriptUrl = '/'.basename($scriptName);
                    }
                } elseif ($scriptName && strlen($scriptName) < strlen($scriptUrl)) {
                    $scriptUrl = '/'.basename($scriptName);
                } else {
                    //$scriptUrl = $scriptUrl;
                }
            } else {
                $scriptUrl = '/'.basename($scriptName);
            }
            
            $this->scriptUrl = htmlentities($scriptUrl);
        }
        
        return $this->scriptUrl;
    }
663368
function () {
        var rootURL = this._getRootURL();
        var path = rootURL;
        var historyPath = this._getHistoryPath();
        var routePath = historyPath.substr(rootURL.length);

        if (routePath !== '') {
          if (routePath.charAt(0) !== '/') {
            routePath = '/' + routePath;
          }

          path += '#' + routePath;
        }

        return path;
      }
729086
protected function _getCurrentUrl() {
        $url = $this->view->fullUrl($this->view->url());
        $quesPos = strpos($url, '?');
        if ($quesPos !== false) {
            $url = substr($url, 0, $quesPos);
        }
        return $url;
    }
271082
public String getRequestURL()
    {
    	HttpServletRequest httpReq = getRequest();
    	if (httpReq==null)
    		return null;
    	else
    		return httpReq.getRequestURL().toString();
    }
1215406
function () {
      var result = '';
      if (this._string) {
        return this._string;
      } else {
        result = this.scheme === undefined ? result : (result + this.scheme + ':');
        result = this.authority === undefined ? result : (result + '//' + this.authority);
        result = result + this.path;
        result = this.query === undefined ? result : (result + '?' + this.query);
        result = this.fragment === undefined ? result : (result + '#' + this.fragment);
        this._string = result;
        return result;
      }
    }
767186
function() {
        return (this.scheme !== null ? this.scheme + "://" : '') +
               (this.host !== null ? this.host : '' ) +
               (this.port !== -1   ? ":" + this.port : '' ) +
               (this.path !== null ? this.path : '' ) +
               (this.qs   !== null ? "?" + this.qs : '' );
    }
830719
public static function getCurrentURL()
    {
        $url = 'http://';
        if (self::isHttps()) {
            $url = 'https://';
        }

        if (isset($_SERVER['PHP_AUTH_USER'])) {
            $url .= $_SERVER['PHP_AUTH_USER'];
            if (isset($_SERVER['PHP_AUTH_PW'])) {
                $url .= ':'.$_SERVER['PHP_AUTH_PW'];
            }
            $url .= '@';
        }
        if (isset($_SERVER['HTTP_HOST'])) {
            $url .= $_SERVER['HTTP_HOST'];
        }
        if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
            $url .= ':'.$_SERVER['SERVER_PORT'];
        }
        if (!isset($_SERVER['REQUEST_URI'])) {
            $url .= substr($_SERVER['PHP_SELF'], 1);
            if (isset($_SERVER['QUERY_STRING'])) {
                $url .= '?'.$_SERVER['QUERY_STRING'];
            }

            return $url;
        }

        $url .= $_SERVER['REQUEST_URI'];

        return $url;
    }
33884
function getCurrentDocumentUrl() {
            var $activePage = $("body").pagecontainer("getActivePage");
            if (null == $activePage) {
                return $.mobile.path.documentBase.hrefNoHash;
            }
            var base = $.mobile.path.documentBase.hrefNoHash;
            var url = $.mobile.activePage.closest(".ui-page").jqmData("url");
            if (!url || !$.mobile.path.isPath(url)) {
                url = base;
            }
            return $.mobile.path.makeUrlAbsolute(url, base);
        }
720658
function getUrlDelay(url) {
    var delay;
    if (options.url && !options.url.test(url)) {
      delay = 0;
    }

    return delay;
  }
1180196
function(){
        var url = window.location.href;
        var vars = {};
        var hashes = url.slice(url.indexOf('#') + 1).split('&');
        for(var i=0; i<hashes.length; i++) {
            var hash = hashes[i].split('=');
            if(hash.length > 1) {
                vars[hash[0]] = hash[1];
            } else {
                vars[hash[0]] = null;
            }
        }
        return vars;
    }
765699
function() {
			// remove any query string
			var cleaned = this.clean(),
				// get the last /
				last = cleaned.lastIndexOf('/'),
			    // if there is a last /, get everything up to that point
				dir = (last != -1) ? cleaned.substring(0, last) : '';
			// make sure we aren't left with just https/ or file:/
			return /^(https?:\/|file:\/)$/.test(dir) ? cleaned : dir;
		}
140972
public static function getWebPath()
    {
        static $path;
        if (empty($path)) {
            
            // 当前文件路径
            $file = Request::instance()->server('SCRIPT_NAME');
            
            // 去除文件名
            $arr = explode('/', $file);
            array_pop($arr);
            
            // 当前文件夹路径
            if (count($arr) == 0) {
                $path = '/';
            } else {
                $path = implode('/', $arr) . '/';
            }
        }
        return $path;
    }