1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const uriTemplate = require("uri-template");
|
4 | const url_1 = require("./utils/url");
|
5 |
|
6 |
|
7 |
|
8 | class Link {
|
9 | constructor(properties) {
|
10 | this.templated = false;
|
11 | this.title = null;
|
12 | this.type = null;
|
13 | for (const key of ['context', 'href', 'name', 'rel', 'templated', 'title', 'type']) {
|
14 | if (properties[key]) {
|
15 | this[key] = properties[key];
|
16 | }
|
17 | }
|
18 | }
|
19 | |
20 |
|
21 |
|
22 | resolve() {
|
23 | return url_1.resolve(this.context, this.href);
|
24 | }
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 | expand(variables) {
|
32 | if (!this.templated) {
|
33 | return url_1.resolve(this.context, this.href);
|
34 | }
|
35 | else {
|
36 | const templ = uriTemplate.parse(this.href);
|
37 | const expanded = templ.expand(variables);
|
38 | return url_1.resolve(this.context, expanded);
|
39 | }
|
40 | }
|
41 | }
|
42 | exports.default = Link;
|
43 |
|
\ | No newline at end of file |