Skip to content

Commit 76597e6

Browse files
authored
impr(settings): Allow webp format for background images (@fehmer) (monkeytypegame#6896)
1 parent 4aeadb9 commit 76597e6

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

frontend/__tests__/root/config.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ describe("Config", () => {
751751
Config.setCustomBackground(" http://example.com/test.png ")
752752
).toBe(true);
753753

754-
expect(Config.setCustomBackground("http://www.example.com/test.webp")).toBe(
754+
expect(Config.setCustomBackground("http://www.example.com/test.tiff")).toBe(
755755
false
756756
);
757757
expect(

frontend/src/html/pages/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@
13761376
<input
13771377
type="file"
13781378
id="customBackgroundUpload"
1379-
accept="image/png,image/jpeg,image/jpg,image/gif"
1379+
accept="image/png,image/jpeg,image/jpg,image/gif,image/webp"
13801380
style="display: none"
13811381
/>
13821382
</div>

frontend/src/ts/commandline/lists/custom-background.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const customBackgroundCommand: Command = {
4242
}
4343

4444
// check type
45-
if (!file.type.match(/image\/(jpeg|jpg|png|gif)/)) {
45+
if (!file.type.match(/image\/(jpeg|jpg|png|gif|webp)/)) {
4646
Notifications.add("Unsupported image format", 0);
4747
cleanup();
4848
return;

frontend/src/ts/elements/settings/custom-background-picker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ uploadContainerEl
5252
}
5353

5454
// check type
55-
if (!file.type.match(/image\/(jpeg|jpg|png|gif)/)) {
55+
if (!file.type.match(/image\/(jpeg|jpg|png|gif|webp)/)) {
5656
Notifications.add("Unsupported image format", 0);
5757
fileInput.value = "";
5858
return;

packages/schemas/src/configs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export const CustomBackgroundSchema = z
345345
.url("Needs to be an URI.")
346346
.regex(/^(https|http):\/\/.*/, "Unsupported protocol.")
347347
.regex(/^[^`'"]*$/, "May not contain quotes.")
348-
.regex(/.+(\.png|\.gif|\.jpeg|\.jpg)/gi, "Unsupported image format.")
348+
.regex(/.+(\.png|\.gif|\.jpeg|\.jpg|\.webp)/gi, "Unsupported image format.")
349349
.max(2048, "URL is too long.")
350350
.or(z.literal(""));
351351
export type CustomBackground = z.infer<typeof CustomBackgroundSchema>;

0 commit comments

Comments
 (0)