Home > OS >  Conversion of JavaScript bolleans
Conversion of JavaScript bolleans

Time:11-27

I am trying to decompress a simple JavaScript code. But I am unable to do it properly.

Compressed Code:

r.match("example.com") && (r.match("=") ? (parts = r.split("="), r = parts[1] && "" != parts[1].trim() ? parts[0]   "=w100-h100" : r) : r  = "=w120-h120");

My Code:

if (r.match("example.com")) {
    if (r.match("=")) {
        parts = r.split("=")
        r = parts[1]
        if ("" != parts[1].trim()) {
            parts[0]   "=w100-h100-p-k-no-nu"
        } else {
            r
        }
    } else {
        r  = "=w120-h120-p-k-no-nu"
    }
}

I am using this tool: https://www.toptal.com/developers/javascript-minifier

CodePudding user response:

Your minified with indentations:

r.match("example.com") && (r.match("=")
    ? (
        parts = r.split("="),
        r = parts[1] && "" != parts[1].trim()
            ? parts[0]   "=w100-h100"
            : r
    )
    : r  = "=w120-h120");

The decoded not minified source with some minor changes.

if (r.includes("example.com")) {
    if (r.includes("=")) {
        const parts = r.split("=");
        if (parts[1].trim()) r = parts[0]   "=w100-h100";
    } else {
        r  = "=w120-h120";
    }
}
  • Related