Skip to content

Commit

Permalink
Merge pull request #867 from plural/generalize-contraction-in-textToId
Browse files Browse the repository at this point in the history
Generalize handling contractions in textToId.
  • Loading branch information
talha-ahsan authored Feb 8, 2025
2 parents 0fee1f6 + d499514 commit c572f53
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function textToId(text: string): string {
.normalize('NFD')
// remove non-ASCII
.replace(/\P{ASCII}/gu, '')
// replace 's followed by a space or end-of-line with s and the space/end match.
.replace(/'s(\s|$)/gu, 's$1')
// replace '\w followed by a space or end-of-line with \w and the space/end match.
.replace(/'(\w)(\s|$)/gu, '$1$2')
// split along space or punction.
.split(/[\s\p{P}]+/u)
// exclude any elements that are empty when trimmed to avoid trailing _ for the join.
Expand Down

0 comments on commit c572f53

Please sign in to comment.