Support ?v= for SVG URLs, too
This commit is contained in:
parent
f6f8d3200a
commit
78354a35d0
1 changed files with 21 additions and 8 deletions
|
@ -159,28 +159,41 @@ const resolvers = {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const assetUrls = asset.assetData.map(
|
||||||
|
(ad) => new URL(ad.path, "http://images.neopets.com")
|
||||||
|
);
|
||||||
|
|
||||||
// In the `lod` case, if there's a JS asset, then don't treat this as an
|
// In the `lod` case, if there's a JS asset, then don't treat this as an
|
||||||
// SVG asset at all. (There might be an SVG in the asset list anyway
|
// SVG asset at all. (There might be an SVG in the asset list anyway
|
||||||
// sometimes I think, for the animation, but ignore it if so!)
|
// sometimes I think, for the animation, but ignore it if so!)
|
||||||
//
|
//
|
||||||
// NOTE: I thiiink the `vector` case is deprecated? I haven't verified
|
// NOTE: I thiiink the `vector` case is deprecated? I haven't verified
|
||||||
// whether it's gone from our database yet, though.
|
// whether it's gone from our database yet, though.
|
||||||
const jsAssetDatum = asset.assetData.find((ad) =>
|
const jsAssetUrl = assetUrls.find(
|
||||||
ad.path.endsWith(".js")
|
// NOTE: Sometimes the path ends with a ?v= query string, so we need
|
||||||
|
// to use `extname` to find the real extension!
|
||||||
|
// TODO: There's a file_ext field in the full manifest, but it's not
|
||||||
|
// included in our cached copy. That would probably be more
|
||||||
|
// reliable!
|
||||||
|
(url) => path.extname(url.pathname) === ".js"
|
||||||
);
|
);
|
||||||
if (jsAssetDatum) {
|
if (jsAssetUrl) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const svgAssetDatum = asset.assetData.find((ad) =>
|
const svgAssetUrl = assetUrls.find(
|
||||||
ad.path.endsWith(".svg")
|
// NOTE: Sometimes the path ends with a ?v= query string, so we need
|
||||||
|
// to use `extname` to find the real extension!
|
||||||
|
// TODO: There's a file_ext field in the full manifest, but it's not
|
||||||
|
// included in our cached copy. That would probably be more
|
||||||
|
// reliable!
|
||||||
|
(url) => path.extname(url.pathname) === ".svg"
|
||||||
);
|
);
|
||||||
if (!svgAssetDatum) {
|
if (!svgAssetUrl) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const url = new URL(svgAssetDatum.path, "http://images.neopets.com");
|
return svgAssetUrl.toString();
|
||||||
return url.toString();
|
|
||||||
},
|
},
|
||||||
canvasMovieLibraryUrl: async ({ id }, _, { db, swfAssetLoader }) => {
|
canvasMovieLibraryUrl: async ({ id }, _, { db, swfAssetLoader }) => {
|
||||||
const layer = await swfAssetLoader.load(id);
|
const layer = await swfAssetLoader.load(id);
|
||||||
|
|
Loading…
Reference in a new issue