Skip to content

0.2.0

Compare
Choose a tag to compare
@karwa karwa released this 19 Nov 10:48
· 140 commits to main since this release

What's Changed

In addition to the changes listed below, the guide has been entirely rewritten, and now does a better job of explaining the WebURL API and object model, and the benefits it can bring to your application/library. The goal is to help you become as comfortable using WebURL as you are using Foundation's URL. It took a lot of work, and I'd really recommend giving it a read. Even if you're not using WebURL yet, the chances are that you'll learn a thing or two about how Foundation's URL actually works.

URL standard

  • Domains which end in numbers must be IPv4 addresses. See here for more information. (whatwg/url#619)
  • The JavaScript model's hostname setter now returns early if a port is given. (whatwg/url#604)
  • The path setter can no longer erase the path of path-only URLs. (whatwg/url#582) (reported by us)

API

  • Support for creating file URLs from file paths, and file paths from file URLs.
  • Added WebURLSystemExtras module which integrates with both swift-system and Apple's System.framework.
  • LazilyPercentDecoded<Collection> is now bidirectional when its source collection is.
  • WebURL.cannotBeABase has been renamed to WebURL.hasOpaquePath, following an update in the standard. (whatwg/url#655) (reported by us)
  • Percent-encoding and -decoding APIs have been reworked to take advantage of static member syntax (SE-0299). A source-compatible fallback is in place for pre-5.5 compilers. This is the reason for duplicate functions appearing in the docs, one with a EncodeSet._Member argument. We're looking at moving to Swift-DocC which will hopefully fix this. The previous API has been back-ported with deprecation notices wherever possible, so the compiler should guide when it comes to updating your applications.
  • It is now possible to percent-decode a string as an array of bytes using the .percentDecodedBytesArray() function. This is useful for dealing with binary data and non-UTF8 strings.
  • The .pathComponents view now assumes inserted data is not percent-encoded, which preserves values exactly if they happen to contain strings which coincidentally look like percent-encoding.
  • A .pathComponents[raw: Index] subscript has been added, which returns a path component exactly as it appears in the URL string, including its percent-encoding.
  • A .pathComponent.replaceSubrange(_:withPercentEncodedComponents:) function has been added for inserting pre-encoded path components.
  • Added Sendable conformance to WebURL, WebURL.Host, IP addresses, origins, and the various wrapper views.
  • The .serialized property has been combined with .serializedExcludingFragment in to a single function: .serialized(excludingFragment: Bool = false).

Implementation

  • Better performance, especially for component setters
  • Component setters are now benchmarked
  • Support for fuzzing the parser
  • Added UnsafeBoundsCheckedBufferPointer which allows us to keep bounds-checking without sacrificing performance
  • Simplified internal storage types, reducing code size
  • Better percent-encoding performance

Full Changelog: 0.1.0...0.2.0

What's coming next

The major goal for 0.3.0 is compatibility with Foundation's URL. At the very least, that is going to include support for creating a URL from a WebURL and vice versa, but we may need additional APIs for a truly great developer experience.