Humanize place type properly, refactor for other tags

This commit is contained in:
2026-01-27 11:20:57 +07:00
parent 104a742543
commit 399ad1822d
6 changed files with 24 additions and 18 deletions

9
app/utils/format-text.js Normal file
View File

@@ -0,0 +1,9 @@
export function humanizeOsmTag(text) {
if (typeof text !== 'string' || !text) return '';
// Replace underscores and dashes with spaces
const spaced = text.replace(/[_-]/g, ' ');
// Capitalize first letter of each word (Title Case)
return spaced.replace(/\w\S*/g, (w) =>
w.replace(/^\w/, (c) => c.toUpperCase())
);
}