Skip to content

Commit 128d94d

Browse files
fix
1 parent 690d0fb commit 128d94d

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

_just/dangerously-insert-files/[email protected]

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ const errors = [
178178
const knownErrors = [
179179
"InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.",
180180
"InvalidCharacterError: Failed to execute 'atob' on 'Window': The string to be decoded contains characters outside of the Latin1 range.",
181-
"TypeError: txt.replaceAll is not a function. (In 'txt.replaceAll(key, value)', 'txt.replaceAll' is undefined)"
181+
"TypeError: txt.replaceAll is not a function. (In 'txt.replaceAll(key, value)', 'txt.replaceAll' is undefined)",
182+
"TypeError: txt.replaceAll is not a function"
182183
]
183184

184185
function checkNum0(num) {
@@ -193,31 +194,23 @@ function checkNum0(num) {
193194
}
194195

195196
function checkNum1(num) {
196-
let data005 = checkNum0(num / 2);
197-
let data006 = checkNum0(num / 3);
198-
let data007 = checkNum0(num / 4);
199-
let data008 = checkNum0(num / 5);
200-
let data009 = checkNum0(num / 6);
201-
let data010 = checkNum0(num / 7);
202-
let data011 = checkNum0(num / 8);
203-
let data012 = checkNum0(num / 9);
204197
return [
205-
data005,
206-
data006,
207-
data007,
208-
data008,
209-
data009,
210-
data010,
211-
data011,
212-
data012
198+
checkNum0(num / 2),
199+
checkNum0(num / 3),
200+
checkNum0(num / 4),
201+
checkNum0(num / 5),
202+
checkNum0(num / 6),
203+
checkNum0(num / 7),
204+
checkNum0(num / 8),
205+
checkNum0(num / 9)
213206
];
214207
}
215208

216209
function encode0(str) {
217-
let data013 = checkNum1(str.length);
210+
let checks = checkNum1(str.length);
218211
let result = [];
219212
for (let i = 2; i <= 9; i++) {
220-
if (data013[i - 2]) {
213+
if (checks[i - 2]) {
221214
let partLength = Math.floor(str.length / i);
222215
let parts = [];
223216
for (let j = 0; j < i; j++) {
@@ -595,6 +588,13 @@ function crypt(input, key) {
595588
}
596589
return output;
597590
}
591+
function throwNewError(catchedError, id_) {
592+
if (knownErrors.some((knownError) => {return knownError == catchedError})) {
593+
throw new Error(`${errors[0]} (${encode(id_, null, true)})`);
594+
} else {
595+
throw new Error(`${errors[1]} (${encode(catchedError, null, true)})`);
596+
}
597+
}
598598

599599
export const encode = (text, key, compress) => {
600600
let encd;
@@ -645,15 +645,15 @@ export const decode = (text, key) => {
645645
try {
646646
decd = decode2(encd);
647647
} catch (decodeError) {
648-
if (knownErrors.some((knownError) => {return knownError == decodeError})) {
649-
throw new Error(errors[0]);
650-
} else {
651-
throw new Error(`${errors[1]} (${encode(decodeError, true)})`);
652-
}
648+
throwNewError(decodeError, 'decode2(encd)');
653649
}
654650
if (dataID == 0 || dataID == 1 || dataID == 2 || dataID == 3) {
655-
let cLang = dataID == 0 ? 'EN' : dataID == 2 ? 'FR' : dataID == 3 ? 'UA' : 'RU';
656-
decd = decompress(decd, cLang);
651+
try {
652+
let cLang = dataID == 0 ? 'EN' : dataID == 2 ? 'FR' : dataID == 3 ? 'UA' : 'RU';
653+
decd = decompress(decd, cLang);
654+
} catch (decompressError) {
655+
throwNewError(decompressError, 'decompress(decd, cLang)');
656+
}
657657
}
658658
}
659659
if (decd.length == 0) {

0 commit comments

Comments
 (0)