Fix NDEF URI casing (#2397)

This commit is contained in:
Jesse Hills 2021-09-27 11:11:27 +13:00 committed by GitHub
parent 4c390d9f9f
commit 756c6721e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View file

@ -21,7 +21,7 @@ NdefRecordUri::NdefRecordUri(const std::vector<uint8_t> &payload) {
this->tnf_ = TNF_WELL_KNOWN;
this->type_ = "U";
this->set_URI(uri);
this->set_uri(uri);
}
std::vector<uint8_t> NdefRecordUri::get_encoded_payload() {
@ -31,7 +31,7 @@ std::vector<uint8_t> NdefRecordUri::get_encoded_payload() {
uint8_t payload_prefix_length = 0x00;
for (uint8_t i = 1; i < PAYLOAD_IDENTIFIERS_COUNT; i++) {
std::string prefix = PAYLOAD_IDENTIFIERS[i];
if (this->URI_.substr(0, prefix.length()).find(prefix) != std::string::npos) {
if (this->uri_.substr(0, prefix.length()).find(prefix) != std::string::npos) {
payload_prefix = i;
payload_prefix_length = prefix.length();
break;
@ -40,7 +40,7 @@ std::vector<uint8_t> NdefRecordUri::get_encoded_payload() {
data.push_back(payload_prefix);
data.insert(data.end(), this->URI_.begin() + payload_prefix_length, this->URI_.end());
data.insert(data.end(), this->uri_.begin() + payload_prefix_length, this->uri_.end());
return data;
}

View file

@ -49,27 +49,27 @@ class NdefRecordUri : public NdefRecord {
public:
NdefRecordUri(){};
NdefRecordUri(const std::vector<uint8_t> &payload);
NdefRecordUri(const std::string &URI) {
NdefRecordUri(const std::string &uri) {
this->tnf_ = TNF_WELL_KNOWN;
this->type_ = "U";
this->URI_ = URI;
this->uri_ = uri;
};
NdefRecordUri(const std::string &URI, const std::string &id) {
NdefRecordUri(const std::string &uri, const std::string &id) {
this->tnf_ = TNF_WELL_KNOWN;
this->type_ = "U";
this->URI_ = URI;
this->uri_ = uri;
this->id_ = id;
};
NdefRecordUri(const NdefRecordUri &) = default;
std::unique_ptr<NdefRecord> clone() const override { return make_unique<NdefRecordUri>(*this); };
void set_URI(const std::string &URI) { this->URI_ = URI; };
void set_uri(const std::string &uri) { this->uri_ = uri; };
std::vector<uint8_t> get_encoded_payload() override;
const std::string &get_payload() const override { return this->URI_; };
const std::string &get_payload() const override { return this->uri_; };
protected:
std::string URI_;
std::string uri_;
};
} // namespace nfc