[whatwg/url] Inconsistency in Handling `special-scheme-missing-following-solidus` URLs (Issue #822)

### What is the issue with the URL Standard?

**Description:**

The current implementation of the WhatWG URL standard exhibits inconsistency in handling `special-scheme-missing-following-solidus` URLs, leading to unexpected behavior and discrepancies across various scenarios. This bug report aims to elucidate the issue and propose a standardized approach for handling such URLs to enhance consistency and predictability.

**Current Behavior:**

The handling of `special-scheme-missing-following-solidus` URLs is outlined in the provided table:

| BASE                 | INPUT                                       | Result                                |
|----------------------|---------------------------------------------|---------------------------------------|
| http://example.com/  | [http:web.site](http://web.site/)           | http://example.com/web.site           |
| http://example.com/  | [https:web.site](https://example/web.site) | https://web.site/            |
| https://example.com/ | [http:web.site](http://web.site/)           | http://web.site/                      |
| https://example.com/ | [https:web.site](https://example.com/web.site) | https://example.com/web.site       |

**Issue:**

The existing handling of `special-scheme-missing-following-solidus` URLs results in inconsistencies, particularly when the URL scheme differs from the base URL scheme. For example, in the second row of the table, the resulting URL is `https://web.site/`, which may not align with user expectations.

**Suggested Improvement:**

To standardize and enhance predictability, I propose adopting one of the following approaches:

1. **Consistent Domain Resolution:**

   Ensure that the resolved URL consistently reflects the domain specified in the input, irrespective of the base URL scheme. This approach fosters consistency across diverse scenarios and mitigates unexpected outcomes.

   Revised Table:
   
   | BASE                 | INPUT                                       | Result                                |
   |----------------------|---------------------------------------------|---------------------------------------|
   | http://example.com/  | [http:web.site](http://web.site/)           | http://web.site           |
   | http://example.com/  | [https:web.site](https://web.site) | http://web.site/            |
   | https://example.com/ | [http:web.site](http://web.site/)           | http://web.site/                      |
   | https://example.com/ | [https:web.site](https://web.site) | https://web.site       |

2. **Preserve Base Domain:**

   Ensure that the resolved URL incorporates the base domain when the input URL does not explicitly specify it. This approach maintains clarity regarding the base domain and yields predictable outcomes when the domain is omitted in the input URL.

   Revised Table:
   
   | BASE                 | INPUT                                       | Result                                |
   |----------------------|---------------------------------------------|---------------------------------------|
   | http://example.com/  | [http:web.site](http://web.site/)           | http://example.com/web.site           |
   | http://example.com/  | [https:web.site](https://example.com/web.site) | http://example.com/web.site/            |
   | https://example.com/ | [http:web.site](http://example.com/web.site)           | https://example.com/web.site/                      |
   | https://example.com/ | [https:web.site](https://example.com/web.site) | https://example.com/web.site       |

**Conclusion:**

Standardizing the handling of `special-scheme-missing-following-solidus` URLs will bolster consistency, predictability, and interoperability across various implementations of the WhatWG URL standard. The proposed improvements aim to rectify the existing inconsistency and ensure a more coherent behavior in URL resolution.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/822
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/url/issues/822@github.com>

Received on Friday, 9 February 2024 13:41:49 UTC