Humanize place type properly, refactor for other tags
This commit is contained in:
9
app/utils/format-text.js
Normal file
9
app/utils/format-text.js
Normal 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())
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user