Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generalize handling contractions in textToId. #867

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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