Skip to content

Commit 25d0058

Browse files
committed
feat: add image/webp to MimeType and MimeTypes
1 parent 39cfc5f commit 25d0058

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/layer/AbstractLayer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,18 @@ export class AbstractLayer {
135135
if (
136136
params.format !== MimeTypes.JPEG &&
137137
params.format !== MimeTypes.PNG &&
138+
params.format !== MimeTypes.WEBP &&
138139
params.format !== MimeTypes.JPEG_OR_PNG
139140
) {
140141
throw new Error(
141142
'Format ' +
142143
params.format +
143144
' not supported, only ' +
144145
MimeTypes.PNG +
145-
' and ' +
146+
', ' +
146147
MimeTypes.JPEG +
148+
' and ' +
149+
MimeTypes.WEBP +
147150
' are allowed',
148151
);
149152
}

src/layer/__tests__/getHugeMap.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ test('getHugeMap should throw an error when format is not supported', async () =
1515
try {
1616
await layer.getHugeMap(getMapParams, ApiType.PROCESSING);
1717
} catch (e) {
18-
expect(e.message).toBe('Format image/tiff not supported, only image/png and image/jpeg are allowed');
18+
expect(e.message).toBe(
19+
'Format image/tiff not supported, only image/png, image/jpeg and image/webp are allowed',
20+
);
1921
}
2022
});

src/layer/const.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ export type MimeType =
129129
| 'text/xml'
130130
| 'image/png'
131131
| 'image/jpeg'
132+
| 'image/webp'
132133
| 'image/tiff'
133134
| 'image/tiff;depth=8'
134135
| 'image/tiff;depth=16'
@@ -139,6 +140,7 @@ export type FormatJpegOrPng = 'JPEG_OR_PNG';
139140
export const MimeTypes: Record<string, MimeType | FormatJpegOrPng> = {
140141
JPEG: 'image/jpeg',
141142
PNG: 'image/png',
143+
WEBP: 'image/webp',
142144
JPEG_OR_PNG: 'JPEG_OR_PNG',
143145
};
144146

0 commit comments

Comments
 (0)