From 6b8cd54fde910aee9928679a18bb8daf84daf03d Mon Sep 17 00:00:00 2001 From: George Hotelling Date: Fri, 7 Dec 2018 10:10:48 -0500 Subject: [PATCH] Add documentation for `safeDecodeURI()` and `filterURLForDisplay()` (#12570) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add documentation for `safeDecodeURI()` and `filterURLForDisplay()` * Whitespace * Consistant Capit… i mean capitalization * Oxford comma Co-Authored-By: georgeh --- packages/url/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/url/README.md b/packages/url/README.md index 4c092d670fc9fd..fb78d8808bb2be 100644 --- a/packages/url/README.md +++ b/packages/url/README.md @@ -167,4 +167,20 @@ const newUrl = removeQueryArgs( 'https://wordpress.org?foo=bar&bar=baz&baz=fooba Removes one or more query string arguments from the given URL. +### safeDecodeURI + +```js +const badUri = safeDecodeURI( '%z' ); // does not throw an Error, simply returns '%z' +``` + +Safely decodes a URI with `decodeURI`. Returns the URI unmodified if `decodeURI` throws an Error. + +### filterURLForDisplay + +```js +const displayUrl = filterURLForDisplay( 'https://www.wordpress.org/gutenberg/' ); // wordpress.org/gutenberg +``` + +Returns a URL for display, without protocol, www subdomain, or trailing slash. +

Code is Poetry.