Re: [web-nfc] Inconsistency on failure to parse URLs and absolute URLs (#623)

You're absolutely right @rakuco. Thanks for catching!
Chromium implementation throws TypeError for both url and absolute-url records.

```cpp

// Create a 'url' record or an 'absolute-url' record.
static NDEFRecord* CreateUrlRecord(const String& id,
                                   const NDEFRecordInit& record,
                                   ExceptionState& exception_state) {
  // https://w3c.github.io/web-nfc/#mapping-url-to-ndef
  if (
      !record.hasData() || !record.data()->IsString()
  ) {
    exception_state.ThrowTypeError(
        "The data for url NDEFRecord must be a String.");
    return nullptr;
  }

  // No need to check mediaType according to the spec.
  const String& url = record.data()->GetAsString();
  if (!KURL(NullURL(), url).IsValid()) {
    exception_state.ThrowDOMException(DOMExceptionCode::kSyntaxError,
                                      "Cannot parse data for url record.");
    return nullptr;
  }

  return MakeGarbageCollected<NDEFRecord>(
      device::mojom::blink::NDEFRecordTypeCategory::kStandardized,
      record.recordType(), id, GetUTF8DataFromString(url));
}
```
See https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/nfc/ndef_record.cc;l=219;drc=3176b81a49dc3811a2b55eb70df6499400d53470?q=absolute-url%20f:nfc%20f:cc$&ss=chromium

I've submitted https://github.com/w3c/web-nfc/pull/624 to address this spec issue.

-- 
GitHub Notification of comment by beaufortfrancois
Please view or discuss this issue at https://github.com/w3c/web-nfc/issues/623#issuecomment-924650154 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 22 September 2021 07:11:06 UTC