Skip to content

Commit

Permalink
Merge pull request zoeyfyi#192 from luisfontes19/full-url-encode
Browse files Browse the repository at this point in the history
full url encode/decode
  • Loading branch information
IvanMathy authored Mar 16, 2021
2 parents adcd6ce + 987f139 commit 00b63f7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Scripts/FullURLDecode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
{
"api":1,
"name":"URL Decode (full)",
"description":"URL Decodes all characters",
"author":"luisfontes19",
"icon":"link",
"tags":"url,decode,full",
}
**/


function fullUrlDecode(str) {
var codes = str.split("%");
var decoded = '';

for (var i = 0; i < codes.length; i++) {
decoded += String.fromCharCode(parseInt(c, 16));
}

return decoded;
}

function main(state) {
state.text = fullUrlDecode(state.text);
}
26 changes: 26 additions & 0 deletions Scripts/FullURLEncode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
{
"api":1,
"name":"URL Encode (full)",
"description":"URL Encodes all characters",
"author":"luisfontes19",
"icon":"link",
"tags":"url,encode,full",
}
**/


function fullUrlEncode(str) {
var encoded = '';

for (var i = 0; i < str.length; i++) {
var h = parseInt(str.charCodeAt(i)).toString(16);
encoded += '%' + h;
}

return encoded;
}

function main(state) {
state.text = fullUrlEncode(state.text);
}

0 comments on commit 00b63f7

Please sign in to comment.