-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added tolerance and ZWNJ split to name
- Loading branch information
1 parent
cfffeaa
commit 6a2b1bc
Showing
11 changed files
with
167 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { describe, it, expect } from 'vitest' | ||
|
||
import { insertZeroWidthNonJoinerAtLabel } from './sharedFunctions' | ||
|
||
|
||
describe('insertZeroWidthNonJoinerAtLabel', () => { | ||
it('should insert a ZWNJ after the first label', () => { | ||
const name = insertZeroWidthNonJoinerAtLabel('name.com') | ||
expect(name).toBe('name\u200C.com') | ||
}) | ||
|
||
it('should insert a ZWNJ after the first label with multiple labels', () => { | ||
const name = insertZeroWidthNonJoinerAtLabel('name.co.uk') | ||
expect(name).toBe('name\u200C.co.uk') | ||
}) | ||
|
||
it('should be able to split resulting name by ZWNJ', () => { | ||
const name = insertZeroWidthNonJoinerAtLabel('name.co.uk') | ||
const [label, ...rest] = name.split('\u200C') | ||
expect(label).toBe('name') | ||
expect(rest.join('')).toBe('.co.uk') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const insertZeroWidthNonJoinerAtLabel = (name: string) => { | ||
const [label, ...rest] = name.split('.') | ||
return [`${label}\u200C`, ...rest].join('.') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters