MCPcopy
hub / github.com/ampproject/amphtml / parseExtensionUrl

Function parseExtensionUrl

src/service/extension-script.js:105–119  ·  view source on GitHub ↗
(scriptUrl)

Source from the content-addressed store, hash-verified

103 * @return {?{extensionId: string, extensionVersion: string}}
104 */
105export 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.

Callers 6

mergeShadowHead_Method · 0.90
handleScriptFunction · 0.90
getExtensionScriptsFunction · 0.85
extensionScriptsInNodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected