# Foundation URL Improvements

**URL:** <https://forums.swift.org/t/foundation-url-improvements/54057>\
**Category:** Core Libraries\
**Tags:** foundation, url\
**Created:** [December 14, 2021, 7:05pm UTC](https://forums.swift.org/t/foundation-url-improvements/54057 "2021-12-14T19:05:12Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Karl](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@Karl](https://forums.swift.org/u/Karl)\
**Post date:** [December 15, 2021, 9:26am UTC](https://forums.swift.org/t/foundation-url-improvements/54057/7 "2021-12-15T09:26:20Z")

</div>

> [@icharleshu](#):
>
> (2) if there are other straightforward changes we should consider to help

How long have you got? 😅

In all seriousness, I think the biggest, easiest improvements would be to:

1. Add `.percentEncodedX` properties to `URL`, so that people don't need to go through `URLComponents` to avoid URL's automatic percent-decoding. Automatic decoding is really, really, really bad and currently there is no way around it (even converting `URL` -\> `URLComponents` will automatically percent-decode under certain circumstances, and can corrupt the path).

2. Add a method which provides the URL's string buffer, with ranges of all of the components. This would be seriously useful for `URL` -\> `WebURL` conversion -- currently, because there are differences between the standards (as well as bugs in URL), we need to request each component individually to ensure the converted URL points to the same location, and each component potentially allocates a `String`.

There are more, but I think these 2 would be relatively straightforward and come with some big wins.

---

_[View the full topic](https://forums.swift.org/t/foundation-url-improvements/54057)._
