Skip to content

Commit 1edd930

Browse files
authored
DEV: Fix custom_header_links migration to handle blank string (#69)
If the old theme setting value is set to a blank string, we will end up not migrating it and thus cause an error to be raised.
1 parent 82d5925 commit 1edd930

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

migrations/settings/0002-migrate-custom-header-links.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function migrate(settings) {
88
return settings;
99
}
1010

11-
if (oldSetting) {
11+
if (typeof oldSetting === "string") {
1212
const newLinks = [];
1313

1414
oldSetting.split("|").forEach((link) => {

test/unit/migrations/settings/0002-migrate-custom-header-links-test.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ module(
4343
);
4444
});
4545

46+
test("migrate when old setting value is an empty string", function (assert) {
47+
const settings = new Map(Object.entries({ custom_header_links: "" }));
48+
49+
const result = migrate(settings);
50+
51+
const expectedResult = new Map(
52+
Object.entries({ custom_header_links: [] })
53+
);
54+
55+
assert.deepEqual(
56+
Object.fromEntries(result.entries()),
57+
Object.fromEntries(expectedResult.entries())
58+
);
59+
});
60+
4661
test("migrate when old setting value is invalid", function (assert) {
4762
const settings = new Map(
4863
Object.entries({

0 commit comments

Comments
 (0)