Compare commits
No commits in common. "64456645124ccff10f1661181aafb68804e61aa7" and "9f584e69a8832e99525f6be049df6dbbddcf7c00" have entirely different histories.
6445664512
...
9f584e69a8
1 changed files with 0 additions and 37 deletions
|
@ -1,37 +0,0 @@
|
||||||
const Command = require("#lib/command.js");
|
|
||||||
const {Icons} = require("#util/constants.js");
|
|
||||||
|
|
||||||
const urldecode = new Command("urldecode");
|
|
||||||
urldecode.category = "misc";
|
|
||||||
urldecode.helpText = "Get information on a URL";
|
|
||||||
urldecode.usage = "<url>";
|
|
||||||
urldecode.callback = async function (msg, line, [urlString]) {
|
|
||||||
try {
|
|
||||||
const url = new URL(urlString);
|
|
||||||
|
|
||||||
const info = [
|
|
||||||
["scheme", url.protocol],
|
|
||||||
["username", url.username],
|
|
||||||
["password", url.password],
|
|
||||||
["host", url.host],
|
|
||||||
["path", url.pathname],
|
|
||||||
["hash", url.hash],
|
|
||||||
];
|
|
||||||
|
|
||||||
return `\`\`\`py
|
|
||||||
${info
|
|
||||||
.filter((kv) => kv[1].length > 0)
|
|
||||||
.map(([k, v]) => `${k} = ${v}`)
|
|
||||||
.join("\n")}
|
|
||||||
|
|
||||||
${JSON.stringify(
|
|
||||||
url.searchParams,
|
|
||||||
(_, v) => (v instanceof URLSearchParams ? Object.fromEntries(v.entries()) : v),
|
|
||||||
"\t"
|
|
||||||
)}
|
|
||||||
\`\`\``;
|
|
||||||
} catch (err) {
|
|
||||||
return `${Icons.silk.error} Failed to decode URL:\n\`\`\`\n${err}\`\`\``;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
hf.registerCommand(urldecode);
|
|
Loading…
Add table
Add a link
Reference in a new issue