Skip to content

Commit 3749d01

Browse files
committed
refactor: move iso-8859-8-i to fallback
1 parent 12b7249 commit 3749d01

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

fallback/single-byte.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import { decode2string } from './_utils.js'
44

55
export const E_STRICT = 'Input is not well-formed for this encoding'
66
const xUserDefined = 'x-user-defined'
7+
const iso8i = 'iso-8859-8-i'
78

89
export const assertEncoding = (encoding) => {
9-
if (Object.hasOwn(encodings, encoding) || encoding === xUserDefined) return
10+
if (Object.hasOwn(encodings, encoding) || encoding === xUserDefined || encoding === iso8i) return
1011
throw new RangeError('Unsupported encoding')
1112
}
1213

@@ -28,6 +29,7 @@ const decoders = new Map()
2829
// Used only on Node.js, no reason to optimize for anything else
2930
// E.g. avoiding .from and filling zero-initialized arr manually is faster on Hermes, but we avoid this codepath on Hermes completely
3031
export function encodingMapper(encoding) {
32+
if (encoding === iso8i) encoding = 'iso-8859-8'
3133
const cached = mappers.get(encoding)
3234
if (cached) return cached
3335

@@ -62,6 +64,7 @@ export function encodingMapper(encoding) {
6264
}
6365

6466
export function encodingDecoder(encoding) {
67+
if (encoding === iso8i) encoding = 'iso-8859-8'
6568
const cached = decoders.get(encoding)
6669
if (cached) return cached
6770

single-byte.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ function shouldUseNative(enc) {
2929
}
3030

3131
export function createSinglebyteDecoder(encoding, loose = false) {
32-
if (encoding === 'iso-8859-8-i') encoding = 'iso-8859-8'
3332
assertEncoding(encoding)
3433

3534
if (canDecoders && shouldUseNative(encoding)) {

single-byte.node.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ function latin1Prefix(arr, start) {
2424
}
2525

2626
export function createSinglebyteDecoder(encoding, loose = false) {
27-
if (encoding === 'iso-8859-8-i') encoding = 'iso-8859-8'
2827
const latin1path = encoding === 'windows-1252'
2928
if (isDeno) {
3029
const jsDecoder = encodingDecoder(encoding) // asserts

0 commit comments

Comments
 (0)