From 7d2cdac22785710a957e5b59c285957ed090bf51 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Thu, 26 Mar 2015 22:25:01 +0100 Subject: [PATCH] reordered plugins: first list encodings, then decodings --- dencode.js | 76 +++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/dencode.js b/dencode.js index 315cae6..405754c 100644 --- a/dencode.js +++ b/dencode.js @@ -12,7 +12,7 @@ }, { "id": "base64encode", - "name": "Base64 encode", + "name": "Encode Base64", "convert": function (input) { return { "status": "OK", @@ -20,9 +20,45 @@ }; } }, + { + "id": "encodeuri", + "name": "Encode URI", + "convert": function (input) { + return { + "status": "OK", + "content": encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']') + }; + } + }, + { + "id": "encodeuricomponent", + "name": "Encode URI component", + "convert": function (input) { + return { + "status": "OK", + "content": encodeURIComponent(input).replace(/[!'()*]/g, function(c) { + return '%' + c.charCodeAt(0).toString(16); + }) + }; + } + }, + { + "id": "encodehtmlentities", + "name": "Encode HTML entities", + "convert": function (input) { + return { + "status": "OK", + "content": input + .replace(/\&/g, "&") + .replace(/\/g, ">") + .replace(/\"/g, """) + }; + } + }, { "id": "base64decode", - "name": "Base64 decode", + "name": "Decode Base64", "convert": function (input) { try { return { @@ -37,16 +73,6 @@ } } }, - { - "id": "encodeuri", - "name": "Encode URI", - "convert": function (input) { - return { - "status": "OK", - "content": encodeURI(input).replace(/%5B/g, '[').replace(/%5D/g, ']') - }; - } - }, { "id": "decodeuri", "name": "Decode URI", @@ -64,18 +90,6 @@ } } }, - { - "id": "encodeuricomponent", - "name": "Encode URI component", - "convert": function (input) { - return { - "status": "OK", - "content": encodeURIComponent(input).replace(/[!'()*]/g, function(c) { - return '%' + c.charCodeAt(0).toString(16); - }) - }; - } - }, { "id": "decodeuricomponent", "name": "Decode URI component", @@ -93,20 +107,6 @@ } } }, - { - "id": "encodehtmlentities", - "name": "Encode HTML entities", - "convert": function (input) { - return { - "status": "OK", - "content": input - .replace(/\&/g, "&") - .replace(/\/g, ">") - .replace(/\"/g, """) - }; - } - }, { "id": "decodehtmlentities", "name": "Decode HTML entities",