c6fc / npk

A mostly-serverless distributed hash cracking platform
508 stars 59 forks source link

Code cleanup #101

Open Privat33r-dev opened 3 months ago

Privat33r-dev commented 3 months ago

Amazing software, thanks for developing and maintaining it! :)

I want to address this part. https://github.com/c6fc/npk/blame/fdcc28266bc931260f2a918f01dad2e6c742717f/lambda_functions/compression_pipe/main.js#L46-L52

Its readability and robustness could be improved by using path.parse(path).name instead.

Failing test case:

const key = "key/with/no/extension.";

const basename = key
        .split('/')
        .pop()
        .split('.')
        .slice(0, -1)
        .join('.')
        .toString();

console.log(basename);  // Expected output: "extension"; Actual output: ""

P.S. Haven't checked all the code, so it might be really unlikely for this scenario to happen, but wanted to address it anyway.