Do not insert _ after , and : separators in emoji names
Change-Id: Ib822ff9f3b2e9b3633f60020435fc8ab8e237025
diff --git a/scripts/update_emoji_db.js b/scripts/update_emoji_db.js
index 1a82339..f409e44 100644
--- a/scripts/update_emoji_db.js
+++ b/scripts/update_emoji_db.js
@@ -62,8 +62,8 @@
// The part after # contains: emoji char, version, name
// Example: " 😇 E1.0 smiling face with halo"
- const commentPart = statusPart[1].trim();
-
+ const commentPart = statusPart[1].trim();
+
// We need to extract the actual emoji character(s) to use as key.
// It's the first 'word' in the comment part usually.
// But extracting it from the code points is safer/standard.
@@ -83,8 +83,8 @@
const nameIndex = commentPart.indexOf(version) + version.length;
name = normalize(commentPart.substring(nameIndex).trim());
} else {
- // Fallback if regex fails (shouldn't happen with standard file)
- console.warn(`Could not parse version for line: ${line}`);
+ // Fallback if regex fails (shouldn't happen with standard file)
+ console.warn(`Could not parse version for line: ${line}`);
}
result[emojiKey] = {
@@ -99,6 +99,10 @@
}
function normalize(str) {
- // Replace spaces with underscores and lowercase
- return str.toLowerCase().replace(/[ \-]+/g, '_');
+ return str
+ .toLowerCase()
+ // Keep Unicode name separators such as ':' and ',' but drop the following space.
+ .replace(/([:,])\s+/g, '$1')
+ // Normalize remaining spaces and hyphens to underscores.
+ .replace(/[ \-]+/g, '_');
}