1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
16 | return new (P || (P = Promise))(function (resolve, reject) {
|
17 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
18 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
19 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
20 | step((generator = generator.apply(thisArg, _arguments || [])).next());
|
21 | });
|
22 | };
|
23 | Object.defineProperty(exports, "__esModule", { value: true });
|
24 |
|
25 |
|
26 |
|
27 |
|
28 | class PrefixedUrlLoader {
|
29 | constructor(prefix, delegate) {
|
30 | this.prefix = prefix;
|
31 | this.delegate = delegate;
|
32 | }
|
33 | canLoad(url) {
|
34 | return url.startsWith(this.prefix) &&
|
35 | this.delegate.canLoad(this._unprefix(url));
|
36 | }
|
37 | load(url) {
|
38 | return __awaiter(this, void 0, void 0, function* () {
|
39 | if (!url.startsWith(this.prefix)) {
|
40 | throw new Error(`Can not load "${url}", does not match prefix "${this.prefix}".`);
|
41 | }
|
42 | return this.delegate.load(this._unprefix(url));
|
43 | });
|
44 | }
|
45 | _unprefix(url) {
|
46 | return url.slice(this.prefix.length);
|
47 | }
|
48 | }
|
49 | exports.PrefixedUrlLoader = PrefixedUrlLoader;
|
50 |
|
\ | No newline at end of file |