1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | const __chunk_1 = require('./stencilrouter-a3d77a87.js');
|
6 | const __chunk_2 = require('./chunk-94c92d88.js');
|
7 |
|
8 |
|
9 | const getUrl = (url, root) => {
|
10 |
|
11 | if (url.charAt(0) == '/' && root.charAt(root.length - 1) == '/') {
|
12 | return root.slice(0, root.length - 1) + url;
|
13 | }
|
14 | return root + url;
|
15 | };
|
16 | class Redirect {
|
17 | constructor(hostRef) {
|
18 | __chunk_1.registerInstance(this, hostRef);
|
19 | }
|
20 | componentWillLoad() {
|
21 | if (this.history && this.root && this.url) {
|
22 | return this.history.replace(getUrl(this.url, this.root));
|
23 | }
|
24 | }
|
25 | get el() { return __chunk_1.getElement(this); }
|
26 | }
|
27 | __chunk_2.ActiveRouter.injectProps(Redirect, [
|
28 | 'history',
|
29 | 'root'
|
30 | ]);
|
31 |
|
32 | exports.stencil_router_redirect = Redirect;
|