| 329 | } |
| 330 | |
| 331 | function _stripOrigin(baseHref: string): string { |
| 332 | // DO NOT REFACTOR! Previously, this check looked like this: |
| 333 | // `/^(https?:)?\/\//.test(baseHref)`, but that resulted in |
| 334 | // syntactically incorrect code after Closure Compiler minification. |
| 335 | // This was likely caused by a bug in Closure Compiler, but |
| 336 | // for now, the check is rewritten to use `new RegExp` instead. |
| 337 | const isAbsoluteUrl = new RegExp('^(https?:)?//').test(baseHref); |
| 338 | if (isAbsoluteUrl) { |
| 339 | const [, pathname] = baseHref.split(/\/\/[^\/]+/); |
| 340 | return pathname; |
| 341 | } |
| 342 | return baseHref; |
| 343 | } |