Base85: Fix alphabetName

This commit is contained in:
Benedikt Werner 2020-05-16 00:42:02 +02:00
parent 4c3324aea1
commit 0182cdda69
No known key found for this signature in database
GPG Key ID: 1DBFF0F8E9E121EB

View File

@ -1,3 +1,5 @@
import Utils from "../Utils.mjs";
/**
* Base85 resources.
*
@ -32,13 +34,12 @@ export const ALPHABET_OPTIONS = [
* @returns {string}
*/
export function alphabetName(alphabet) {
alphabet = alphabet.replace("'", "'");
alphabet = alphabet.replace("\"", """);
alphabet = alphabet.replace("\\", "\");
alphabet = escape(alphabet);
let name;
ALPHABET_OPTIONS.forEach(function(a) {
if (escape(alphabet) === escape(a.value)) name = a.name;
const expanded = Utils.expandAlphRange(a.value).join("");
if (alphabet === escape(expanded)) name = a.name;
});
return name;