From e52b8813117c6fa56d7ca1582d76e27d21529ba7 Mon Sep 17 00:00:00 2001 From: Craig Hutchison Date: Sat, 6 Feb 2021 21:28:28 -0500 Subject: [PATCH 1/4] Add underscores for Windows tile config "windows80Ie10Tile" and "windows10Ie11EdgeTiles" config options need to have underscores before both sets of numbers. Converting from camelCase to underscore previously yielded "windows80_ie10_tile" and "windows10_ie11_edge_tiles", which was incorrect. After the change the conversion now yields the correct values of "windows_80_ie_10_tile" and "windows_10_ie_11_edge_tiles". --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 07a63a8..06e6d06 100755 --- a/index.js +++ b/index.js @@ -116,7 +116,11 @@ module.exports.init = function() { }; exports.camelCaseToUnderscore = function(s) { - return s.replace(/(?:^|\.?)([A-Z])/g, function(x,y) { + // Regex will also insert an underscore before a digit if that digit is preceded by a lowercase letter and followed + // by one or more additional digits, so it will insert an underscore before the "8" and the "1" in + // "windows80Ie10Tile" (yielding "windows_80_ie_10_tile", but NOT before the "6" in "ios6AndPriorIcons" (yielding + // "ios6_and_prior_icons"). + return s.replace(/(?:^|\.?)([A-Z]|(?<=[a-z])\d(?=\d+))/g, function(x,y) { return "_" + y.toLowerCase() }).replace(/^_/, ""); } From 00b2447c546a0063808a78ffa2bd243efc47c87c Mon Sep 17 00:00:00 2001 From: Craig Hutchison Date: Sat, 6 Feb 2021 21:47:24 -0500 Subject: [PATCH 2/4] Exclude color values from regex pattern color "#134f97" was getting converted to "#134f_97", so adding additional requirement that number must be followed by an uppercase letter --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 06e6d06..7c6765f 100755 --- a/index.js +++ b/index.js @@ -120,7 +120,7 @@ module.exports.init = function() { // by one or more additional digits, so it will insert an underscore before the "8" and the "1" in // "windows80Ie10Tile" (yielding "windows_80_ie_10_tile", but NOT before the "6" in "ios6AndPriorIcons" (yielding // "ios6_and_prior_icons"). - return s.replace(/(?:^|\.?)([A-Z]|(?<=[a-z])\d(?=\d+))/g, function(x,y) { + return s.replace(/(?:^|\.?)([A-Z]|(?<=[a-z])\d(?=\d+[A-Z]))/g, function(x,y) { return "_" + y.toLowerCase() }).replace(/^_/, ""); } From 3797385ac72747898e72b65164814d5422775250 Mon Sep 17 00:00:00 2001 From: Craig Hutchison Date: Sat, 6 Feb 2021 22:18:16 -0500 Subject: [PATCH 3/4] explicitly exclude colors from underscore conversion exclude "background_color" and "theme_color" from camelCase to underscore conversion --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 7c6765f..8198750 100755 --- a/index.js +++ b/index.js @@ -120,7 +120,7 @@ module.exports.init = function() { // by one or more additional digits, so it will insert an underscore before the "8" and the "1" in // "windows80Ie10Tile" (yielding "windows_80_ie_10_tile", but NOT before the "6" in "ios6AndPriorIcons" (yielding // "ios6_and_prior_icons"). - return s.replace(/(?:^|\.?)([A-Z]|(?<=[a-z])\d(?=\d+[A-Z]))/g, function(x,y) { + return s.replace(/(?:^|\.?)([A-Z]|(?<=[a-z])\d(?=\d+))/g, function(x,y) { return "_" + y.toLowerCase() }).replace(/^_/, ""); } @@ -154,7 +154,9 @@ module.exports.init = function() { 'app_description', 'developer_name', 'app_name', - 'existing_manifest']; + 'existing_manifest', + 'background_color', + 'theme_color']; var newContent = (keysToIgnore.indexOf(uKey) >= 0) ? request[key] : exports.camelCaseToUnderscoreRequest(request[key]); From a0b2602a2adac6ac02c22f05fd0eb29b780fb5d0 Mon Sep 17 00:00:00 2001 From: Craig Hutchison Date: Sat, 6 Feb 2021 22:30:18 -0500 Subject: [PATCH 4/4] put array closing bracket on newline to avoid potential merge conflicts --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8198750..f23ed65 100755 --- a/index.js +++ b/index.js @@ -156,7 +156,8 @@ module.exports.init = function() { 'app_name', 'existing_manifest', 'background_color', - 'theme_color']; + 'theme_color' + ]; var newContent = (keysToIgnore.indexOf(uKey) >= 0) ? request[key] : exports.camelCaseToUnderscoreRequest(request[key]);