diff --git a/src/api/generate-manifest-icons-entry.ts b/src/api/generate-manifest-icons-entry.ts index 7f13687..dbe1568 100644 --- a/src/api/generate-manifest-icons-entry.ts +++ b/src/api/generate-manifest-icons-entry.ts @@ -8,14 +8,14 @@ export function generateManifestIconsEntry( for (const icon of Object.values(instruction.transparent)) { icons.icons.push({ - src: icon.name, + src: icon.url, sizes: `${icon.width}x${icon.height}`, type: icon.mimeType, }) } for (const icon of Object.values(instruction.maskable)) { icons.icons.push({ - src: icon.name, + src: icon.url, sizes: `${icon.width}x${icon.height}`, type: icon.mimeType, purpose: 'maskable', diff --git a/test/__snapshots__/manifest-icons.test.ts.snap b/test/__snapshots__/manifest-icons.test.ts.snap index 1dd3241..472cbc5 100644 --- a/test/__snapshots__/manifest-icons.test.ts.snap +++ b/test/__snapshots__/manifest-icons.test.ts.snap @@ -5,23 +5,51 @@ exports[`should generate manifest icons entry 1`] = ` "icons": [ { "sizes": "64x64", - "src": "pwa-64x64.png", + "src": "/pwa-64x64.png", "type": "image/png", }, { "sizes": "192x192", - "src": "pwa-192x192.png", + "src": "/pwa-192x192.png", "type": "image/png", }, { "sizes": "512x512", - "src": "pwa-512x512.png", + "src": "/pwa-512x512.png", "type": "image/png", }, { "purpose": "maskable", "sizes": "512x512", - "src": "maskable-icon-512x512.png", + "src": "/maskable-icon-512x512.png", + "type": "image/png", + }, + ], +} +`; + +exports[`should generate manifest icons entry with custom base 1`] = ` +{ + "icons": [ + { + "sizes": "64x64", + "src": "/test/pwa-64x64.png", + "type": "image/png", + }, + { + "sizes": "192x192", + "src": "/test/pwa-192x192.png", + "type": "image/png", + }, + { + "sizes": "512x512", + "src": "/test/pwa-512x512.png", + "type": "image/png", + }, + { + "purpose": "maskable", + "sizes": "512x512", + "src": "/test/maskable-icon-512x512.png", "type": "image/png", }, ], diff --git a/test/manifest-icons.test.ts b/test/manifest-icons.test.ts index 6e7d7ae..201fa12 100644 --- a/test/manifest-icons.test.ts +++ b/test/manifest-icons.test.ts @@ -23,3 +23,22 @@ it('should generate manifest icons entry', async () => { expectTypeOf(icons).toEqualTypeOf() expect(icons).toMatchSnapshot() }) + +it('should generate manifest icons entry with custom base', async () => { + const instructions = await resolveInstructions({ + imageResolver: () => readFile('playground/pwa/public/favicon.svg'), + imageName: 'playground/pwa/public/favicon.svg', + preset: 'minimal-2023', + htmlLinks: { + xhtml: false, + includeId: false, + }, + basePath: '/test/', + resolveSvgName: name => basename(name), + }) + const iconsString = generateManifestIconsEntry('string', instructions) + expectTypeOf(iconsString).toEqualTypeOf() + const icons = generateManifestIconsEntry('object', instructions) + expectTypeOf(icons).toEqualTypeOf() + expect(icons).toMatchSnapshot() +})