Files
ts-scripts/single-scripts/encode-uri-component.ts
2026-02-11 23:30:02 +08:00

32 lines
826 B
TypeScript
Executable File

#!/usr/bin/env runts -- --allow-import
import {args, exit, stdinToArrayBuffer,} from "https://script.hatter.ink/@43/deno-commons-mod.ts";
import {parseArgs} from "jsr:@std/cli/parse-args";
const flags = parseArgs(args(), {
boolean: ["help"],
string: ["value"],
alias: {
V: "value",
},
});
if (flags.help) {
console.log("echo value | encode-uri-component.ts");
console.log("encode-uri-component.ts --value <value>");
exit(0);
}
let input;
if (flags.value) {
input = flags.value;
} else {
input = new TextDecoder().decode(await stdinToArrayBuffer());
}
const encoded = encodeURIComponent(input);
console.log(encoded);
// @SCRIPT-SIGNATURE-V1: yk-r1.ES256.20260211T232943+08:00.MEQCIHBCH6zw/wB9EHEA2gjw
// xPNLvrWiV1wRk4cMtDs5BUE4AiBowpBMCz34b+yGESBlDAktw2BPqpuFC6aZo7zieHH2eA==