cryptocoinjs / hdkey

JavaScript component for Bitcoin hierarchical deterministic keys (BIP32)
MIT License
201 stars 74 forks source link

Clean dirty derivePath check #31

Closed chiro-hiro closed 4 years ago

chiro-hiro commented 4 years ago

I've found this: https://github.com/cryptocoinjs/hdkey/blob/master/lib/hdkey.js#L73

  if (path === 'm' || path === 'M' || path === "m'" || path === "M'") {
    return this
  }

Why not this?:

  if ((/^m(|\')$/i).test(path)){
     return this
  }
junderw commented 4 years ago

I love Regex, I used to work in translation and coded plugins for them which used regex extensively.

That said, many MANY of my colleagues can't read regex and don't understand it.

Readability loss here is much larger than the utility gain.

So I will have to NACK this idea.

Thanks though, if you have any other suggestions I would love to hear them.

Hope you have a great 2020!