1 | import { r as registerInstance, g as getElement } from './stencilrouter-1307249c.js';
|
2 | import { A as ActiveRouter } from './chunk-cfc6485e.js';
|
3 |
|
4 |
|
5 | const getUrl = (url, root) => {
|
6 |
|
7 | if (url.charAt(0) == '/' && root.charAt(root.length - 1) == '/') {
|
8 | return root.slice(0, root.length - 1) + url;
|
9 | }
|
10 | return root + url;
|
11 | };
|
12 | class Redirect {
|
13 | constructor(hostRef) {
|
14 | registerInstance(this, hostRef);
|
15 | }
|
16 | componentWillLoad() {
|
17 | if (this.history && this.root && this.url) {
|
18 | return this.history.replace(getUrl(this.url, this.root));
|
19 | }
|
20 | }
|
21 | get el() { return getElement(this); }
|
22 | }
|
23 | ActiveRouter.injectProps(Redirect, [
|
24 | 'history',
|
25 | 'root'
|
26 | ]);
|
27 |
|
28 | export { Redirect as stencil_router_redirect };
|