From bb6bc4cac330120e691a4a0566ff547342f62c0c Mon Sep 17 00:00:00 2001 From: Richard Moore Date: Tue, 27 Nov 2018 15:59:14 -0500 Subject: [PATCH] Check for partially-working normalize support. --- src.ts/errors.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src.ts/errors.ts b/src.ts/errors.ts index 84daf9fba..d64ce470a 100644 --- a/src.ts/errors.ts +++ b/src.ts/errors.ts @@ -125,10 +125,19 @@ export function setCensorship(censorship: boolean, permanent?: boolean): void { export function checkNormalize(): void { try { + // Make sure all forms of normalization are supported + ["NFD", "NFC", "NFKD", "NFKC"].forEach((form) => { + try { + "test".normalize(form); + } catch(error) { + throw new Error('missing ' + form); + } + }); + if (String.fromCharCode(0xe9).normalize('NFD') !== String.fromCharCode(0x65, 0x0301)) { - throw new Error('broken') + throw new Error('broken implementation') } } catch (error) { - throwError('platform missing String.prototype.normalize', UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize' }); + throwError('platform missing String.prototype.normalize', UNSUPPORTED_OPERATION, { operation: 'String.prototype.normalize', form: error.message }); } }