diff options
| author | Terry Truong <terry06890@gmail.com> | 2022-06-17 23:23:30 +1000 |
|---|---|---|
| committer | Terry Truong <terry06890@gmail.com> | 2022-06-17 23:23:30 +1000 |
| commit | 2dc9cb2f46d57180b1f6ed78d214d6a09d591d7a (patch) | |
| tree | 3c63c23c9ca6c535f81b636dd092a1dc915479ae /src/lib.ts | |
| parent | b22b5e6c0ce07cfc62bed354744178458abcbf35 (diff) | |
Avoid capitalisation of apostrophe-s in tile-names
Diffstat (limited to 'src/lib.ts')
| -rw-r--r-- | src/lib.ts | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -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 |
