Skip to content

Commit dbca772

Browse files
authored
Updating the UrlSet notes.
1 parent 92fa390 commit dbca772

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ URL Tools is a helper library whose sole purpose is making that process just a l
77
- `ParsedUrl`, a wrapper for the standard WHATWG `URL` class that mixes in the domain and subdomain parsing from [`tldjs`](https://www.npmjs.com/package/tldjs). Serializing a `ParsedUrl` object to JSON also produces a broken out collection of its individual properties, rather than spitting out the `href` property, as is the `URL` class's habit.
88
- A collection set of helper functions for URL filtering and normalizing operations, including sorting querystring parameters, stripping social sharing cruft, remapping 'ww1', 'ww2', etc. subdomains to a single canonical one, identifying web vs. non-web URLs, flagging urls on public hosting like S3, and more.
99
- `NormalizedUrl`, a version of `ParsedUrl` that applies one of those normalizer functions automatically on instantiation. Functions that accept a `URL` or `ParsedURL` as a parameter can use `if (url instanceof NormalizedUrl)` to determine whether a given incoming URL has already been normalized. Yay.
10-
- `UrlSet`, a generic set that stores, de-duplicates, and (when used in conjunction with `NormalizedUrl`) normalizes piles of Urls. It's a bit janky, since ES6's `Set` implementation only supports value comparison, and it relies on TypeScript's generics to handle child class behaviors. As such it maintains some inefficient internal collections and requires type be passed in as a Generic and as the first parameter to its constructor, like so: `new UrlSet<NormalizedUrl>(NormalizedUrl, urlStrings);`. Once you get past that annoyance it's a quick way to efficiently take a pile of strings and turn them into clean, consistently-formatted URLs..
10+
- `UrlSet`, `ParsedUrlSet`, and `NormalizedUrlSet`, a trio of Set classes that store, de-duplicate, and normalize piles of Urls in bulk. It's a bit fussy with bulk adding of relative URLs, but you can pass in a 'fallback base url' that helps in some circumstances.

0 commit comments

Comments
 (0)