(path: string, direction: RouterDirection = 'forward', animation?: AnimationBuilder)
| 141 | */ |
| 142 | @Method() |
| 143 | async push(path: string, direction: RouterDirection = 'forward', animation?: AnimationBuilder) { |
| 144 | if (path.startsWith('.')) { |
| 145 | const currentPath = this.previousPath ?? '/'; |
| 146 | // Convert currentPath to an URL by pre-pending a protocol and a host to resolve the relative path. |
| 147 | const url = new URL(path, `https://host/${currentPath}`); |
| 148 | path = url.pathname + url.search + url.hash; |
| 149 | } |
| 150 | |
| 151 | let parsedPath = parsePath(path); |
| 152 | |
| 153 | const canProceed = await this.runGuards(parsedPath.segments); |
| 154 | if (canProceed !== true) { |
| 155 | if (typeof canProceed === 'object') { |
| 156 | parsedPath = parsePath(canProceed.redirect); |
| 157 | } else { |
| 158 | return false; |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | this.setSegments(parsedPath.segments, direction, parsedPath.queryString, parsedPath.fragment); |
| 163 | const result = await this.writeNavStateRoot(parsedPath.segments, direction, animation); |
| 164 | if (result) { |
| 165 | this.maybeScrollToFragment(); |
| 166 | } |
| 167 | |
| 168 | return result; |
| 169 | } |
| 170 | |
| 171 | /** Go back to previous page in the window.history. */ |
| 172 | @Method() |
no test coverage detected