(scriptUrl)
| 103 | * @return {?{extensionId: string, extensionVersion: string}} |
| 104 | */ |
| 105 | export function parseExtensionUrl(scriptUrl) { |
| 106 | if (!scriptUrl) { |
| 107 | return null; |
| 108 | } |
| 109 | // Note that the "(\.max)?" group only applies to local dev. |
| 110 | const matches = scriptUrl.match( |
| 111 | /^(.*)\/(.*)-([0-9.]+|latest)(\.max)?\.(?:js|mjs)(?:\?ssr-css=[0|1])?$/i |
| 112 | ); |
| 113 | const extensionId = matches ? matches[2] : undefined; |
| 114 | const extensionVersion = matches ? matches[3] : undefined; |
| 115 | if (!extensionId || !extensionVersion) { |
| 116 | return null; |
| 117 | } |
| 118 | return {extensionId, extensionVersion}; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Create the missing amp extension HTML script element. |
no outgoing calls
no test coverage detected