Expand description
URL parser and formatter that gracefully handles invalid input.
This is a tool for pretty-printing user-supplied urls plus a url parser that makes it possible.
use mdurl::format_url_for_humans as format;
let url = "https://www.reddit.com/r/programming/comments/vxttiq/\
comment/ifyqsqt/?utm_source=reddit&utm_medium=web2x&context=3";
assert_eq!(format(url, 20), "reddit.com/…/ifyqsq…");
assert_eq!(format(url, 30), "www.reddit.com/r/…/ifyqsqt/?u…");
assert_eq!(format(url, 50), "www.reddit.com/r/programming/comments/…/ifyqsqt/?…");
Structs§
Functions§
- format_
url_ for_ computers - Normalize and encode url.
- format_
url_ for_ humans - Pretty-print url and fit it into N characters (url elision).
- parse_
url - Parse URL string and return a Url object.