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