From 2b1e64849f35b09b5bc52b862dab81bb6e5e1325 Mon Sep 17 00:00:00 2001 From: Jake Boone Date: Mon, 23 Aug 2021 10:10:13 -0700 Subject: [PATCH] Add support for unicode fraction slash --- src/index.test.ts | 3 +++ src/index.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/src/index.test.ts b/src/index.test.ts index 848cc19..8dca565 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -68,4 +68,7 @@ it('works', () => { expect(numericQuantity('2 \u2155')).toBe(2.2); // 2 1/5 // Mixed unicode vulgar fraction - no space expect(numericQuantity('2\u2155')).toBe(2.2); // 2 1/5 + // Unicode fraction slash + expect(numericQuantity('1⁄2')).toBe(0.5); + expect(numericQuantity('2 1⁄2')).toBe(2.5); }); diff --git a/src/index.ts b/src/index.ts index 5b05c37..f2ceca3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -35,6 +35,7 @@ function numericQuantity(qty: string) { vulgarFractionsRegex, (_m, vf: keyof typeof VulgarFraction) => ` ${VulgarFraction[vf]}` ) + .replace(/⁄/g, '/') .trim(); /**