diff --git a/src/app/WardrobePage/support/ItemLayerSupportModal.js b/src/app/WardrobePage/support/ItemLayerSupportModal.js index 710f148..3191e21 100644 --- a/src/app/WardrobePage/support/ItemLayerSupportModal.js +++ b/src/app/WardrobePage/support/ItemLayerSupportModal.js @@ -146,7 +146,7 @@ function ItemLayerSupportModal({ as="a" size="xs" target="_blank" - href={getManifestUrlFromSwfUrl(itemLayer.swfUrl)} + href={convertSwfUrlToManifestUrl(itemLayer.swfUrl)} colorScheme="teal" > Manifest @@ -507,8 +507,18 @@ function ItemLayerSupportModalRemoveButton({ ); } -function getManifestUrlFromSwfUrl(swfUrl) { - return swfUrl.replace("/swf/", "/data/").replace(/\.swf$/, "/manifest.json"); +const SWF_URL_PATTERN = /^http:\/\/images\.neopets\.com\/cp\/(.+?)\/swf\/(.+?)_[a-z0-9]+\.swf$/; + +function convertSwfUrlToManifestUrl(swfUrl) { + const match = swfUrl.match(SWF_URL_PATTERN); + if (!match) { + throw new Error(`unexpected SWF URL format: ${JSON.stringify(swfUrl)}`); + } + + const type = match[1]; + const folders = match[2]; + + return `http://images.neopets.com/cp/${type}/data/${folders}/manifest.json`; } export default ItemLayerSupportModal; diff --git a/src/server/neopets-assets.js b/src/server/neopets-assets.js index d34a3e4..93564b6 100644 --- a/src/server/neopets-assets.js +++ b/src/server/neopets-assets.js @@ -23,7 +23,7 @@ async function loadAssetManifest(swfUrl) { }; } -const SWF_URL_PATTERN = /^http:\/\/images\.neopets\.com\/cp\/(.+?)\/swf\/(.+?)\.swf$/; +const SWF_URL_PATTERN = /^http:\/\/images\.neopets\.com\/cp\/(.+?)\/swf\/(.+?)_[a-z0-9]+\.swf$/; function convertSwfUrlToManifestUrl(swfUrl) { const match = swfUrl.match(SWF_URL_PATTERN); @@ -31,7 +31,8 @@ function convertSwfUrlToManifestUrl(swfUrl) { throw new Error(`unexpected SWF URL format: ${JSON.stringify(swfUrl)}`); } - const [_, type, folders] = match; + const type = match[1]; + const folders = match[2]; return `http://images.neopets.com/cp/${type}/data/${folders}/manifest.json`; }