Re: [whatwg/url] Define the "extract an origin" operation. (PR #892)

@shannonbooth commented on this pull request.



> @@ -3495,6 +3495,11 @@ null-or-<a>scalar value string</a> <var>base</var> (default null), and then runs
 </ol>
 </div>
 
+<div algorithm="URL/extract an origin">
+<p>Objects implementing the {{URL}} interface's <a for="platform object">extract an origin</a> steps are
+to return <a>this</a>'s <a for=URL>URL</a>'s <a for=url>origin</a>. [[!HTML]]

Something that I noticed is not covered by WPT is the below case:

```js
let url = new URL('data:text/plain,opaque');
const origin1 = Origin.from(url);
const origin2 = Origin.from(url);
console.log(origin1.isSameOrigin(origin2));
```

From reading https://url.spec.whatwg.org/#concept-url-origin it seems like the result will be false with current specification:

> -> Otherwise
>     Return a new [opaque origin](https://html.spec.whatwg.org/multipage/browsers.html#concept-origin-opaque).
>
> NOTE: This does indeed mean that these [URLs](https://url.spec.whatwg.org/#concept-url) cannot be [same origin](https://html.spec.whatwg.org/multipage/browsers.html#same-origin) with themselves.

A similar case also happens for https://html.spec.whatwg.org/multipage/links.html#api-for-a-and-area-elements:extract-an-origin I believe

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/pull/892#pullrequestreview-3553795319
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/pull/892/review/3553795319@github.com>

Received on Monday, 8 December 2025 19:48:55 UTC