cnabio / cnab-go

A Go implementation of CNAB Core 1.0
MIT License
69 stars 35 forks source link

TrimPrefix and TrimLeft are NOT the same #257

Closed carolynvs closed 3 years ago

carolynvs commented 3 years ago

I accidentally used TrimLeft instead of TrimPrefix when reading outputs from the claimstore. TrimLeft removes every character found in a string(cutset) from a string until it hits one that isn't found. TrimPrefix removes the specified string from the beginning of a string.

This can cause a bug where if any character found in the result id (a ulid) is the first character of the output's name, e.g. the result id has a 0 in it and the output name starts with 0, then extra characters from the output name are incorrectly trimmed as well, resulting in being unable to read that output back from the claimstore. 🤦‍♀️