first the decoders, then the encoders

This commit is contained in:
Manuel Friedli 2015-03-26 22:51:00 +01:00
parent 7d2cdac227
commit d62498023a

View file

@ -10,52 +10,6 @@
}; };
} }
}, },
{
"id": "base64encode",
"name": "Encode Base64",
"convert": function (input) {
return {
"status": "OK",
"content": btoa(input)
};
}
},
{
"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, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
};
}
},
{ {
"id": "base64decode", "id": "base64decode",
"name": "Decode Base64", "name": "Decode Base64",
@ -127,6 +81,52 @@
}; };
} }
} }
},
{
"id": "base64encode",
"name": "Encode Base64",
"convert": function (input) {
return {
"status": "OK",
"content": btoa(input)
};
}
},
{
"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, "&amp;")
.replace(/\</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
};
}
} }
]; ];