- From: François Beaufort via GitHub <sysbot+gh@w3.org>
- Date: Fri, 18 Oct 2019 09:10:11 +0000
- To: public-web-nfc@w3.org
beaufortfrancois has just created a new issue for https://github.com/w3c/web-nfc: == NDEFRecord mediaType should be non null for media records == I'd like to make sure mapping is symmetric as much as possible and one bit that seems off is `mediaType`. NDEFRecordInit mediaType is unused for all records but media. However NDEFRecord mediaType is set for "text", "url", "external type", "local type", and "unknown". ```js const writer = new NFCWriter(); await writer.push({ records: [ { recordType: 'media', mediaType: 'application/octet-stream', data: new ArrayBuffer() }, { recordType: 'text', data: 'hello' } ]}); const reader = new NFCReader(); reader.scan(); reader.onreading = event => { const decoder = new TextDecoder(); for (const record of event.message.records) { if (record.recordType === 'media') { console.assert(record.mediaType === 'application/octet-stream'); } else if (record.recordType === 'text') { // I didn't provide one so it should be empty. // And if I had provided a valid mediaType but different from 'text/plain' it would be unexpected. console.assert(record.mediaType === ''); // Same would apply to "url" } }; ``` Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/387 using your GitHub account
Received on Friday, 18 October 2019 09:10:13 UTC