[6a3a178] | 1 | /**
|
---|
| 2 | * @license
|
---|
| 3 | * Copyright Google LLC All Rights Reserved.
|
---|
| 4 | *
|
---|
| 5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
| 6 | * found in the LICENSE file at https://angular.io/license
|
---|
| 7 | */
|
---|
| 8 | /**
|
---|
| 9 | * Create a {@link UrlResolver} with no package prefix.
|
---|
| 10 | */
|
---|
| 11 | export function createUrlResolverWithoutPackagePrefix() {
|
---|
| 12 | return new UrlResolver();
|
---|
| 13 | }
|
---|
| 14 | export function createOfflineCompileUrlResolver() {
|
---|
| 15 | return new UrlResolver('.');
|
---|
| 16 | }
|
---|
| 17 | export const UrlResolver = class UrlResolverImpl {
|
---|
| 18 | constructor(_packagePrefix = null) {
|
---|
| 19 | this._packagePrefix = _packagePrefix;
|
---|
| 20 | }
|
---|
| 21 | /**
|
---|
| 22 | * Resolves the `url` given the `baseUrl`:
|
---|
| 23 | * - when the `url` is null, the `baseUrl` is returned,
|
---|
| 24 | * - if `url` is relative ('path/to/here', './path/to/here'), the resolved url is a combination of
|
---|
| 25 | * `baseUrl` and `url`,
|
---|
| 26 | * - if `url` is absolute (it has a scheme: 'http://', 'https://' or start with '/'), the `url` is
|
---|
| 27 | * returned as is (ignoring the `baseUrl`)
|
---|
| 28 | */
|
---|
| 29 | resolve(baseUrl, url) {
|
---|
| 30 | let resolvedUrl = url;
|
---|
| 31 | if (baseUrl != null && baseUrl.length > 0) {
|
---|
| 32 | resolvedUrl = _resolveUrl(baseUrl, resolvedUrl);
|
---|
| 33 | }
|
---|
| 34 | const resolvedParts = _split(resolvedUrl);
|
---|
| 35 | let prefix = this._packagePrefix;
|
---|
| 36 | if (prefix != null && resolvedParts != null &&
|
---|
| 37 | resolvedParts[_ComponentIndex.Scheme] == 'package') {
|
---|
| 38 | let path = resolvedParts[_ComponentIndex.Path];
|
---|
| 39 | prefix = prefix.replace(/\/+$/, '');
|
---|
| 40 | path = path.replace(/^\/+/, '');
|
---|
| 41 | return `${prefix}/${path}`;
|
---|
| 42 | }
|
---|
| 43 | return resolvedUrl;
|
---|
| 44 | }
|
---|
| 45 | };
|
---|
| 46 | /**
|
---|
| 47 | * Extract the scheme of a URL.
|
---|
| 48 | */
|
---|
| 49 | export function getUrlScheme(url) {
|
---|
| 50 | const match = _split(url);
|
---|
| 51 | return (match && match[_ComponentIndex.Scheme]) || '';
|
---|
| 52 | }
|
---|
| 53 | // The code below is adapted from Traceur:
|
---|
| 54 | // https://github.com/google/traceur-compiler/blob/9511c1dafa972bf0de1202a8a863bad02f0f95a8/src/runtime/url.js
|
---|
| 55 | /**
|
---|
| 56 | * Builds a URI string from already-encoded parts.
|
---|
| 57 | *
|
---|
| 58 | * No encoding is performed. Any component may be omitted as either null or
|
---|
| 59 | * undefined.
|
---|
| 60 | *
|
---|
| 61 | * @param opt_scheme The scheme such as 'http'.
|
---|
| 62 | * @param opt_userInfo The user name before the '@'.
|
---|
| 63 | * @param opt_domain The domain such as 'www.google.com', already
|
---|
| 64 | * URI-encoded.
|
---|
| 65 | * @param opt_port The port number.
|
---|
| 66 | * @param opt_path The path, already URI-encoded. If it is not
|
---|
| 67 | * empty, it must begin with a slash.
|
---|
| 68 | * @param opt_queryData The URI-encoded query data.
|
---|
| 69 | * @param opt_fragment The URI-encoded fragment identifier.
|
---|
| 70 | * @return The fully combined URI.
|
---|
| 71 | */
|
---|
| 72 | function _buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) {
|
---|
| 73 | const out = [];
|
---|
| 74 | if (opt_scheme != null) {
|
---|
| 75 | out.push(opt_scheme + ':');
|
---|
| 76 | }
|
---|
| 77 | if (opt_domain != null) {
|
---|
| 78 | out.push('//');
|
---|
| 79 | if (opt_userInfo != null) {
|
---|
| 80 | out.push(opt_userInfo + '@');
|
---|
| 81 | }
|
---|
| 82 | out.push(opt_domain);
|
---|
| 83 | if (opt_port != null) {
|
---|
| 84 | out.push(':' + opt_port);
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 | if (opt_path != null) {
|
---|
| 88 | out.push(opt_path);
|
---|
| 89 | }
|
---|
| 90 | if (opt_queryData != null) {
|
---|
| 91 | out.push('?' + opt_queryData);
|
---|
| 92 | }
|
---|
| 93 | if (opt_fragment != null) {
|
---|
| 94 | out.push('#' + opt_fragment);
|
---|
| 95 | }
|
---|
| 96 | return out.join('');
|
---|
| 97 | }
|
---|
| 98 | /**
|
---|
| 99 | * A regular expression for breaking a URI into its component parts.
|
---|
| 100 | *
|
---|
| 101 | * {@link https://tools.ietf.org/html/rfc3986#appendix-B} says
|
---|
| 102 | * As the "first-match-wins" algorithm is identical to the "greedy"
|
---|
| 103 | * disambiguation method used by POSIX regular expressions, it is natural and
|
---|
| 104 | * commonplace to use a regular expression for parsing the potential five
|
---|
| 105 | * components of a URI reference.
|
---|
| 106 | *
|
---|
| 107 | * The following line is the regular expression for breaking-down a
|
---|
| 108 | * well-formed URI reference into its components.
|
---|
| 109 | *
|
---|
| 110 | * <pre>
|
---|
| 111 | * ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?
|
---|
| 112 | * 12 3 4 5 6 7 8 9
|
---|
| 113 | * </pre>
|
---|
| 114 | *
|
---|
| 115 | * The numbers in the second line above are only to assist readability; they
|
---|
| 116 | * indicate the reference points for each subexpression (i.e., each paired
|
---|
| 117 | * parenthesis). We refer to the value matched for subexpression <n> as $<n>.
|
---|
| 118 | * For example, matching the above expression to
|
---|
| 119 | * <pre>
|
---|
| 120 | * http://www.ics.uci.edu/pub/ietf/uri/#Related
|
---|
| 121 | * </pre>
|
---|
| 122 | * results in the following subexpression matches:
|
---|
| 123 | * <pre>
|
---|
| 124 | * $1 = http:
|
---|
| 125 | * $2 = http
|
---|
| 126 | * $3 = //www.ics.uci.edu
|
---|
| 127 | * $4 = www.ics.uci.edu
|
---|
| 128 | * $5 = /pub/ietf/uri/
|
---|
| 129 | * $6 = <undefined>
|
---|
| 130 | * $7 = <undefined>
|
---|
| 131 | * $8 = #Related
|
---|
| 132 | * $9 = Related
|
---|
| 133 | * </pre>
|
---|
| 134 | * where <undefined> indicates that the component is not present, as is the
|
---|
| 135 | * case for the query component in the above example. Therefore, we can
|
---|
| 136 | * determine the value of the five components as
|
---|
| 137 | * <pre>
|
---|
| 138 | * scheme = $2
|
---|
| 139 | * authority = $4
|
---|
| 140 | * path = $5
|
---|
| 141 | * query = $7
|
---|
| 142 | * fragment = $9
|
---|
| 143 | * </pre>
|
---|
| 144 | *
|
---|
| 145 | * The regular expression has been modified slightly to expose the
|
---|
| 146 | * userInfo, domain, and port separately from the authority.
|
---|
| 147 | * The modified version yields
|
---|
| 148 | * <pre>
|
---|
| 149 | * $1 = http scheme
|
---|
| 150 | * $2 = <undefined> userInfo -\
|
---|
| 151 | * $3 = www.ics.uci.edu domain | authority
|
---|
| 152 | * $4 = <undefined> port -/
|
---|
| 153 | * $5 = /pub/ietf/uri/ path
|
---|
| 154 | * $6 = <undefined> query without ?
|
---|
| 155 | * $7 = Related fragment without #
|
---|
| 156 | * </pre>
|
---|
| 157 | * @internal
|
---|
| 158 | */
|
---|
| 159 | const _splitRe = new RegExp('^' +
|
---|
| 160 | '(?:' +
|
---|
| 161 | '([^:/?#.]+)' + // scheme - ignore special characters
|
---|
| 162 | // used by other URL parts such as :,
|
---|
| 163 | // ?, /, #, and .
|
---|
| 164 | ':)?' +
|
---|
| 165 | '(?://' +
|
---|
| 166 | '(?:([^/?#]*)@)?' + // userInfo
|
---|
| 167 | '([\\w\\d\\-\\u0100-\\uffff.%]*)' + // domain - restrict to letters,
|
---|
| 168 | // digits, dashes, dots, percent
|
---|
| 169 | // escapes, and unicode characters.
|
---|
| 170 | '(?::([0-9]+))?' + // port
|
---|
| 171 | ')?' +
|
---|
| 172 | '([^?#]+)?' + // path
|
---|
| 173 | '(?:\\?([^#]*))?' + // query
|
---|
| 174 | '(?:#(.*))?' + // fragment
|
---|
| 175 | '$');
|
---|
| 176 | /**
|
---|
| 177 | * The index of each URI component in the return value of goog.uri.utils.split.
|
---|
| 178 | * @enum {number}
|
---|
| 179 | */
|
---|
| 180 | var _ComponentIndex;
|
---|
| 181 | (function (_ComponentIndex) {
|
---|
| 182 | _ComponentIndex[_ComponentIndex["Scheme"] = 1] = "Scheme";
|
---|
| 183 | _ComponentIndex[_ComponentIndex["UserInfo"] = 2] = "UserInfo";
|
---|
| 184 | _ComponentIndex[_ComponentIndex["Domain"] = 3] = "Domain";
|
---|
| 185 | _ComponentIndex[_ComponentIndex["Port"] = 4] = "Port";
|
---|
| 186 | _ComponentIndex[_ComponentIndex["Path"] = 5] = "Path";
|
---|
| 187 | _ComponentIndex[_ComponentIndex["QueryData"] = 6] = "QueryData";
|
---|
| 188 | _ComponentIndex[_ComponentIndex["Fragment"] = 7] = "Fragment";
|
---|
| 189 | })(_ComponentIndex || (_ComponentIndex = {}));
|
---|
| 190 | /**
|
---|
| 191 | * Splits a URI into its component parts.
|
---|
| 192 | *
|
---|
| 193 | * Each component can be accessed via the component indices; for example:
|
---|
| 194 | * <pre>
|
---|
| 195 | * goog.uri.utils.split(someStr)[goog.uri.utils.CompontentIndex.QUERY_DATA];
|
---|
| 196 | * </pre>
|
---|
| 197 | *
|
---|
| 198 | * @param uri The URI string to examine.
|
---|
| 199 | * @return Each component still URI-encoded.
|
---|
| 200 | * Each component that is present will contain the encoded value, whereas
|
---|
| 201 | * components that are not present will be undefined or empty, depending
|
---|
| 202 | * on the browser's regular expression implementation. Never null, since
|
---|
| 203 | * arbitrary strings may still look like path names.
|
---|
| 204 | */
|
---|
| 205 | function _split(uri) {
|
---|
| 206 | return uri.match(_splitRe);
|
---|
| 207 | }
|
---|
| 208 | /**
|
---|
| 209 | * Removes dot segments in given path component, as described in
|
---|
| 210 | * RFC 3986, section 5.2.4.
|
---|
| 211 | *
|
---|
| 212 | * @param path A non-empty path component.
|
---|
| 213 | * @return Path component with removed dot segments.
|
---|
| 214 | */
|
---|
| 215 | function _removeDotSegments(path) {
|
---|
| 216 | if (path == '/')
|
---|
| 217 | return '/';
|
---|
| 218 | const leadingSlash = path[0] == '/' ? '/' : '';
|
---|
| 219 | const trailingSlash = path[path.length - 1] === '/' ? '/' : '';
|
---|
| 220 | const segments = path.split('/');
|
---|
| 221 | const out = [];
|
---|
| 222 | let up = 0;
|
---|
| 223 | for (let pos = 0; pos < segments.length; pos++) {
|
---|
| 224 | const segment = segments[pos];
|
---|
| 225 | switch (segment) {
|
---|
| 226 | case '':
|
---|
| 227 | case '.':
|
---|
| 228 | break;
|
---|
| 229 | case '..':
|
---|
| 230 | if (out.length > 0) {
|
---|
| 231 | out.pop();
|
---|
| 232 | }
|
---|
| 233 | else {
|
---|
| 234 | up++;
|
---|
| 235 | }
|
---|
| 236 | break;
|
---|
| 237 | default:
|
---|
| 238 | out.push(segment);
|
---|
| 239 | }
|
---|
| 240 | }
|
---|
| 241 | if (leadingSlash == '') {
|
---|
| 242 | while (up-- > 0) {
|
---|
| 243 | out.unshift('..');
|
---|
| 244 | }
|
---|
| 245 | if (out.length === 0)
|
---|
| 246 | out.push('.');
|
---|
| 247 | }
|
---|
| 248 | return leadingSlash + out.join('/') + trailingSlash;
|
---|
| 249 | }
|
---|
| 250 | /**
|
---|
| 251 | * Takes an array of the parts from split and canonicalizes the path part
|
---|
| 252 | * and then joins all the parts.
|
---|
| 253 | */
|
---|
| 254 | function _joinAndCanonicalizePath(parts) {
|
---|
| 255 | let path = parts[_ComponentIndex.Path];
|
---|
| 256 | path = path == null ? '' : _removeDotSegments(path);
|
---|
| 257 | parts[_ComponentIndex.Path] = path;
|
---|
| 258 | return _buildFromEncodedParts(parts[_ComponentIndex.Scheme], parts[_ComponentIndex.UserInfo], parts[_ComponentIndex.Domain], parts[_ComponentIndex.Port], path, parts[_ComponentIndex.QueryData], parts[_ComponentIndex.Fragment]);
|
---|
| 259 | }
|
---|
| 260 | /**
|
---|
| 261 | * Resolves a URL.
|
---|
| 262 | * @param base The URL acting as the base URL.
|
---|
| 263 | * @param to The URL to resolve.
|
---|
| 264 | */
|
---|
| 265 | function _resolveUrl(base, url) {
|
---|
| 266 | const parts = _split(encodeURI(url));
|
---|
| 267 | const baseParts = _split(base);
|
---|
| 268 | if (parts[_ComponentIndex.Scheme] != null) {
|
---|
| 269 | return _joinAndCanonicalizePath(parts);
|
---|
| 270 | }
|
---|
| 271 | else {
|
---|
| 272 | parts[_ComponentIndex.Scheme] = baseParts[_ComponentIndex.Scheme];
|
---|
| 273 | }
|
---|
| 274 | for (let i = _ComponentIndex.Scheme; i <= _ComponentIndex.Port; i++) {
|
---|
| 275 | if (parts[i] == null) {
|
---|
| 276 | parts[i] = baseParts[i];
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
| 279 | if (parts[_ComponentIndex.Path][0] == '/') {
|
---|
| 280 | return _joinAndCanonicalizePath(parts);
|
---|
| 281 | }
|
---|
| 282 | let path = baseParts[_ComponentIndex.Path];
|
---|
| 283 | if (path == null)
|
---|
| 284 | path = '/';
|
---|
| 285 | const index = path.lastIndexOf('/');
|
---|
| 286 | path = path.substring(0, index + 1) + parts[_ComponentIndex.Path];
|
---|
| 287 | parts[_ComponentIndex.Path] = path;
|
---|
| 288 | return _joinAndCanonicalizePath(parts);
|
---|
| 289 | }
|
---|
| 290 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXJsX3Jlc29sdmVyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXIvc3JjL3VybF9yZXNvbHZlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSDs7R0FFRztBQUNILE1BQU0sVUFBVSxxQ0FBcUM7SUFDbkQsT0FBTyxJQUFJLFdBQVcsRUFBRSxDQUFDO0FBQzNCLENBQUM7QUFFRCxNQUFNLFVBQVUsK0JBQStCO0lBQzdDLE9BQU8sSU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VxuICogICAgJDIgPSA8dW5kZWZpbmVkPiAgICAgICB1c2VySW5mbyAtXFxcbiAqICAgICQzID0gd3d3Lmljcy51Y2kuZWR1ICAgZG9tYWluICAgICB8IGF1dGhvcml0eVxuICogICAgJDQgPSA8dW5kZWZpbmVkPiAgICAgICBwb3J0ICAgICAtL1xuICogICAgJDUgPSAvcHViL2lldGYvdXJpLyAgICBwYXRoXG4gKiAgICAkNiA9IDx1bmRlZmluZWQ+ICAgICAgIHF1ZXJ5IHdpdGhvdXQgP1xuICogICAgJDcgPSBSZWxhdGVkICAgICAgICAgICBmcmFnbWVudCB3aXRob3V0ICNcbiAqIDwvcHJlPlxuICogQGludGVybmFsXG4gKi9cbmNvbnN0IF9zcGxpdFJlID0gbmV3IFJlZ0V4cChcbiAgICAnXicgK1xuICAgICcoPzonICtcbiAgICAnKFteOi8/Iy5dKyknICsgIC8vIHNjaGVtZSAtIGlnbm9yZSBzcGVjaWFsIGNoYXJhY3RlcnNcbiAgICAgICAgICAgICAgICAgICAgIC8vIHVzZWQgYnkgb3RoZXIgVVJMIHBhcnRzIHN1Y2ggYXMgOixcbiAgICAgICAgICAgICAgICAgICAgIC8vID8sIC8sICMsIGFuZCAuXG4gICAgJzopPycgK1xuICAgICcoPzovLycgK1xuICAgICcoPzooW14vPyNdKilAKT8nICsgICAgICAgICAgICAgICAgICAvLyB1c2VySW5mb1xuICAgICcoW1xcXFx3XFxcXGRcXFxcLVxcXFx1MDEwMC1cXFxcdWZmZmYuJV0qKScgKyAgLy8gZG9tYWluIC0gcmVzdHJpY3QgdG8gbGV0dGVycyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZGlnaXRzLCBkYXNoZXMsIGRvdHMsIHBlcmNlbnRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gZXNjYXBlcywgYW5kIHVuaWNvZGUgY2hhcmFjdGVycy5cbiAgICAnKD86OihbMC05XSspKT8nICsgICAg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