Skip to content

Commit

Permalink
Add documentation for safeDecodeURI() and filterURLForDisplay() (#…
Browse files Browse the repository at this point in the history
…12570)

* Add documentation for `safeDecodeURI()` and `filterURLForDisplay()`

* Whitespace

* Consistant Capit… i mean capitalization

* Oxford comma

Co-Authored-By: georgeh <george@hotelling.net>
  • Loading branch information
georgeh authored and chrisvanpatten committed Dec 7, 2018
1 parent 50cafdd commit 6b8cd54
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/url/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>

0 comments on commit 6b8cd54

Please sign in to comment.