From 2dc9cb2f46d57180b1f6ed78d214d6a09d591d7a Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Fri, 17 Jun 2022 23:23:30 +1000 Subject: Avoid capitalisation of apostrophe-s in tile-names --- src/lib.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib.ts') diff --git a/src/lib.ts b/src/lib.ts index c13992c..67ac4c3 100644 --- a/src/lib.ts +++ b/src/lib.ts @@ -108,8 +108,9 @@ export function randWeightedChoice(weights: number[]): number | null { } // Returns a string with words first-letter capitalised export function capitalizeWords(str: string){ - return str.replace(/\b\w/g, x => x.toUpperCase()); - // '\b' matches word boundary, '\w' is like [a-zA-Z0-9_], + str = str.replace(/\b\w/g, x => x.toUpperCase()); // '\b' matches word boundary, '\w' is like [a-zA-Z0-9_] + str = str.replace(/(\w)'S/, '$1\'s'); // Avoid cases like "traveler's tree" -> "Traveler'S Tree" + return str; } // Dynamically obtains scroll bar width // From stackoverflow.com/questions/13382516/getting-scroll-bar-width-using-javascript -- cgit v1.2.3