将`模块标识+'.extension'`形式的字符串转换成相对的url

@ignore
@param {string} source 源字符串
@return {string}
495690
function toUrl( source ) {
        // 分离 模块标识 和 .extension
        var extReg = /(\.[a-z0-9]+)$/i;
        var queryReg = /(\?[^#]*)$/;
        var extname = '';
        var id = source;
        var query = '';

        if ( queryReg.test( source ) ) {
            query = RegExp.$1;
            source = source.replace( queryReg, '' );
        }

        if ( extReg.test( source ) ) {
            extname = RegExp.$1;
            id = source.replace( extReg, '' );
        }

        var url = id;

        // paths处理和匹配
        var isPathMap;
        each( pathsIndex, function ( item ) {
            var key = item.k;
            if ( createPrefixRegexp( key ).test( id ) ) {
                url = url.replace( key, item.v );
                isPathMap = 1;
                return false;
            }
        } );

        // packages处理和匹配
        if ( !isPathMap ) {
            each(
                packagesIndex,
                function ( packageConf ) {
                    var name = packageConf.name;
                    if ( createPrefixRegexp( name ).test( id ) ) {
                        url = url.replace( name, packageConf.location );
                        return false;
                    }
                }
            );
        }

        // 相对路径时，附加baseUrl
        if ( !/^([a-z]{2,10}:\/)?\//i.test( url ) ) {
            url = requireConf.baseUrl + url;
        }

        // 附加 .extension 和 query
        url += extname + query;


        var isUrlArgsAppended;

        /**
         * 为url附加urlArgs
         *
         * @ignore
         * @param {string} args urlArgs串
         */
        function appendUrlArgs( args ) {
            if ( !isUrlArgsAppended ) {
                url += ( url.indexOf( '?' ) > 0 ? '&' : '?' ) + args;
                isUrlArgsAppended = 1;
            }
        }

        // urlArgs处理和匹配
        each( urlArgsIndex, function ( item ) {
            if ( createPrefixRegexp( item.k ).test( id ) ) {
                appendUrlArgs( item.v );
                return false;
            }
        } );
        defaultUrlArgs && appendUrlArgs( defaultUrlArgs );

        return url;
    }
81556
function urlBuilder(params) {
  var builtUrl = params.base;

  builtUrl += '?';

  if (params.apiKey) {
    builtUrl += 'key=' + params.apiKey + '&';
  }

  if (params.client) {
    builtUrl += 'client=' + params.client + '&';
  }

  if (params.libraries.length > 0) {
    builtUrl += 'libraries=';

    params.libraries.forEach(function(library, index) {
      builtUrl += library;

      if (index !== params.libraries.length - 1) {
        builtUrl += ',';
      }
    });

    builtUrl += '&';
  }

  if (params.language) {
    builtUrl += 'language=' + params.language + '&';
  }

  if (params.version) {
    builtUrl += 'v=' + params.version + '&';
  }

  builtUrl += 'callback=' + params.callback;

  return builtUrl;
}
16491
public static String encodeUrlSafe(String source, String charset) {
		return encodeUrlSafe(StrUtil.bytes(source, charset), charset);
	}
933070
function appendQueryString(url, params){
        var key;
        url = url || '';
        if(params){
            if(url.indexOf('?') === -1){
                url += '?';
            }
            if(typeof params === 'string'){
                url += params;
            } else if (typeof params === 'object'){
                for(key in params){
                    if(!/[?&]$/.test(url)){
                        url += '&';
                    }
                    url += encodeURIComponent(key) + '=' + encodeURIComponent(params[key]);
                }
            }
        }

        return url;
    }
1057770
function evalExpression(sourceUrl$$1, ctx, vars) {
    var /** @type {?} */ fnBody = ctx.toSource() + "\n//# sourceURL=" + sourceUrl$$1;
    var /** @type {?} */ fnArgNames = [];
    var /** @type {?} */ fnArgValues = [];
    for (var /** @type {?} */ argName in vars) {
        fnArgNames.push(argName);
        fnArgValues.push(vars[argName]);
    }
    if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__angular_core__["t" /* isDevMode */])()) {
        // using `new Function(...)` generates a header, 1 line of no arguments, 2 lines otherwise
        // E.g. ```
        // function anonymous(a,b,c
        // /**/) { ... }```
        // We don't want to hard code this fact, so we auto detect it via an empty function first.
        var /** @type {?} */ emptyFn = new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat('return null;'))))().toString();
        var /** @type {?} */ headerLines = emptyFn.slice(0, emptyFn.indexOf('return null;')).split('\n').length - 1;
        fnBody += "\n" + ctx.toSourceMapGenerator(sourceUrl$$1, sourceUrl$$1, headerLines).toJsComment();
    }
    return new (Function.bind.apply(Function, [void 0].concat(fnArgNames.concat(fnBody))))().apply(void 0, fnArgValues);
}
1198613
function getSource(fn, altSource) {
    var result = altSource;
    if (isStringable(fn)) {
      result = String(fn);
    } else if (support.decompilation) {
      // escape the `{` for Firefox 1
      result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1];
    }
    return (result || '').replace(/^\s+|\s+$/g, '');
  }
567704
function toUrl(source, baseId) {
        // 分离 模块标识 和 .extension
        var extReg = /(\.[a-z0-9]+)$/i;
        var queryReg = /(\?[^#]*)$/;
        var extname = '';
        var id = source;
        var query = '';

        if (queryReg.test(source)) {
            query = RegExp.$1;
            source = source.replace(queryReg, '');
        }

        if (extReg.test(source)) {
            extname = RegExp.$1;
            id = source.replace(extReg, '');
        }

        if (baseId != null) {
            id = normalize(id, baseId);
        }

        var url = id;

        // paths处理和匹配
        var isPathMap;
        indexRetrieve(id, pathsIndex, function (value, key) {
            url = url.replace(key, value);
            isPathMap = 1;
        });

        // packages处理和匹配
        if (!isPathMap) {
            indexRetrieve(id, packagesIndex, function (value, key, item) {
                url = url.replace(item.name, item.location);
            });
        }

        // 相对路径时，附加baseUrl
        if (!/^([a-z]{2,10}:\/)?\//i.test(url)) {
            url = requireConf.baseUrl + url;
        }

        // 附加 .extension 和 query
        url += extname + query;

        // urlArgs处理和匹配
        indexRetrieve(id, urlArgsIndex, function (value) {
            url += (url.indexOf('?') > 0 ? '&' : '?') + value;
        });

        return url;
    }
710833
function parseExpr(source) {
    if (!source) {
        return;
    }

    if (typeof source === 'object' && source.type) {
        return source;
    }

    var expr = readTertiaryExpr(new Walker(source));
    expr.raw = source;
    return expr;
}
613916
function processUrls(code)
    {
        var gt = /(.*)((&gt;|&lt;).*)/;

        return code.replace(sh.regexLib.url, function(m)
        {
            var suffix = '',
                match = null
                ;

            // We include &lt; and &gt; in the URL for the common cases like <http://google.com>
            // The problem is that they get transformed into &lt;http://google.com&gt;
            // Where as &gt; easily looks like part of the URL string.

            if (match = gt.exec(m))
            {
                m = match[1];
                suffix = match[2];
            }

            return '<a href="' + m + '">' + m + '</a>' + suffix;
        });
    }
873578
function makeRelPath(sourceUrl, targetUrl) {
  var source = sourceUrl.pathname;
  var target = targetUrl.pathname;
  var s = source.split('/');
  var t = target.split('/');
  while (s.length && s[0] === t[0]){
    s.shift();
    t.shift();
  }
  for (var i = 0, l = s.length - 1; i < l; i++) {
    t.unshift('..');
  }
  // empty '#' is discarded but we need to preserve it.
  var hash = (targetUrl.href.slice(-1) === URL_HASH) ? URL_HASH : targetUrl.hash;
  return t.join('/') + targetUrl.search + hash;
}
427117
function matchesExtension(requestedUrl, opts) {
  var exts = !opts.ext || Array.isArray(opts.ext) ?
    opts.ext : [opts.ext];

  if (exts) {
    return exts.some(function(ext) {
      return requestedUrl.pathname.substr(ext.length * -1) === ext;
    });
  }
}
33170
public static String encodeUrlSafe(String source, String charset) {
		return Base64Encoder.encodeUrlSafe(source, charset);
	}
407188
function (source) {

                var str = String(source)
                    .replace(/&quot;/g, '"')
                    .replace(/&lt;/g, '<')
                    .replace(/&gt;/g, '>')
                    .replace(/&amp;/g, '&');

                // 处理转义的中文和实体字符
                return str.replace(/&#([\d]+);/g, function ($0, $1) {
                    return String.fromCharCode(parseInt($1, 10));
                });
            }
442008
function getExtension(file) {
        var ret;
        if (file) {
            var fileTypes = file.split('.');
            var len = fileTypes.length;
            if (0 === len) {
                return ret;
            }
            ret = fileTypes[len - 1];
            return ret;
        }
    }
45395
function updateCSSContentUrl(content, file, pkg, context) {
    return fis.compile.extCss(content, function (m, comment, url, last, filter) {
        url || (url = filter);
        if (url) {
            var leftQuot = '';
            var rightQuot = '';
            var processUrl = url.replace(/^('|")([^'"]+)('|")$/,
                function (all, lquot, uri, rquot) {
                    leftQuot = lquot || '';
                    rightQuot = rquot || '';
                    return uri;
                }
            );
            var uri = context.resolvePath(processUrl, file);

            if (uri === processUrl) {
                return m;
            }

            var msg = {
                target: uri,
                file: pkg,
                ret: uri
            };

            /**
             * @event plugin:relative:fetch 获取相对路径的事件
             */
            fis.emit('plugin:relative:fetch', msg);

            m = m.replace(url, leftQuot + msg.ret + rightQuot);
        }

        return m;
    }, file);
}
423566
function extendClass(source){
      var proto = this.prototype;

      if (typeof source == 'function' && !isClass(source))
        source = source(this.superClass_.prototype, slice(proto));

      if (source.prototype)
        source = source.prototype;

      for (var key in source)
      {
        var value = source[key];
        var protoValue = proto[key];

        if (key == 'className' || key == 'extendConstructor_')
          this[key] = value;
        else
        {
          if (protoValue && protoValue.__extend__)
            proto[key] = protoValue.__extend__(value);
          else
          {
            proto[key] = value;
            ///** @cut */ if (value && !value.__extend__ && (value.constructor == Object || value.constructor == Array)){ consoleMethods.warn('!' + key); }
          }
        }
      }

      // for browsers that doesn't enum toString
      if (TOSTRING_BUG && source[key = 'toString'] !== toString)
        proto[key] = source[key];

      return this;
    }
1140387
function astFromSource(options, source, extension, cb) {
  if (typeof cb === 'undefined') {
    cb = extension;
    extension = null;
  }
  pegParser(options, extension, function (err, parser, key) {
    if (err) {
      return cb(err);
    }
    var ast;
    try {
      ast = parser.parse(source);
      addLineNumbers(ast, source);
      if (ast.type === 'program') {
        ast.type = 'script';
      } else if (ast.type === 'markdown') {
        ast.content = source;
      }
      ast.grammarFile = key;
      // adding in comment nodes, in case they get added to the grammar later
      walk(ast, function (node) {
        if (!node.comments && node.type !== 'undefined') {
          node.comments = [];
        }
      });
      //console.log(JSON.stringify(ast, null, 2));
    } catch (e) {
      return cb(e);
    }
    return cb(null, ast);
  });
}