mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
Convert URL operations
Delete legacy URL module
This commit is contained in:
parent
c9e9499106
commit
b8d39f49b2
4 changed files with 181 additions and 118 deletions
44
src/core/operations/URLDecode.mjs
Normal file
44
src/core/operations/URLDecode.mjs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2016
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation";
|
||||
|
||||
/**
|
||||
* URL Decode operation
|
||||
*/
|
||||
class URLDecode extends Operation {
|
||||
|
||||
/**
|
||||
* URLDecode constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "URL Decode";
|
||||
this.module = "URL";
|
||||
this.description = "Converts URI/URL percent-encoded characters back to their raw values.<br><br>e.g. <code>%3d</code> becomes <code>=</code>";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
const data = input.replace(/\+/g, "%20");
|
||||
try {
|
||||
return decodeURIComponent(data);
|
||||
} catch (err) {
|
||||
return unescape(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default URLDecode;
|
Loading…
Add table
Add a link
Reference in a new issue