don/ndef-js

Prefix or not?

andersborgabiro opened this issue · 1 comments

Is it given that there will always be a prefix, considering this code always slices off the first character in the byte array when parsing, or is it known whether that will be the case beforehand?

I did this as a fail-safe. This is not the exact same context, but you see what I do anyway. Sorry for no use of let etc.

    var payload = "";
    var first = record.payload[0];
    if (first < 32) {
        payload = nfcProtocols[first] + nfc.bytesToString(record.payload.slice(1));
    } else {
        payload = nfc.bytesToString(record.payload);
    }

i also noted there are more than 32 elements in the array.

I figured it out: when type is 85 there's always a prefix that can be from 0 to 35.