* Computes the base url for sourcemaps. Custom sourcemap URLs have placeholder * {version} that should be replaced with the actual version. Also, ensures * that a trailing slash exists. * @param {object} options * @return {string}
(options)
| 11 | * @return {string} |
| 12 | */ |
| 13 | function getSourceRoot(options) { |
| 14 | if (argv.sourcemap_url) { |
| 15 | return String(argv.sourcemap_url) |
| 16 | .replace(/\{version\}/g, internalRuntimeVersion) |
| 17 | .replace(/([^/])$/, '$1/'); |
| 18 | } |
| 19 | if (options.fortesting || !argv._.includes('dist')) { |
| 20 | return 'http://localhost:8000/'; |
| 21 | } |
| 22 | return `https://raw.githubusercontent.com/ampproject/amphtml/${internalRuntimeVersion}/`; |
| 23 | } |
| 24 | |
| 25 | module.exports = {getSourceRoot}; |