Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/odnoletkov/urlnormalize
Normalize a URL
https://github.com/odnoletkov/urlnormalize
normalization url
Last synced: 11 days ago
JSON representation
Normalize a URL
- Host: GitHub
- URL: https://github.com/odnoletkov/urlnormalize
- Owner: odnoletkov
- Created: 2022-05-16T22:40:00.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-30T21:01:24.000Z (over 2 years ago)
- Last Synced: 2024-12-13T21:07:45.601Z (11 days ago)
- Topics: normalization, url
- Language: Swift
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# URLNormalize
[Normalize](https://en.wikipedia.org/wiki/URI_normalization) a URL
```swift
XCTAssertEqual(
URL(string: "HTTP://example.com/foo%2a/./bar/..//baz/?b=v&a=v")?
.normalized().absoluteString,
"http://example.com/foo*/baz?a=v&b=v"
)XCTAssertEqual(
URL(string: "http://example.com/")?
.normalized(options: [.forceHTTPS, .removeTrailingSlash]).absoluteString,
"https://example.com"
)
```See available [normalization options](https://github.com/odnoletkov/URLNormalize/blob/c5f48474cdaa4e20f1c8e7422ee12e9ef9ca1548/Sources/URLNormalize/URLNormalize.swift#L15-L100).
## References
* https://en.wikipedia.org/wiki/URI_normalization
* https://github.com/sindresorhus/normalize-url