Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for safeDecodeURI() and filterURLForDisplay() #12570

Merged
merged 4 commits into from
Dec 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/url/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,19 @@ 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'
```
georgeh marked this conversation as resolved.
Show resolved Hide resolved
Safely decodes a URI with `decodeURI`. Returns the URI unmodified if `decodeURI` throws an error.
georgeh marked this conversation as resolved.
Show resolved Hide resolved

### 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.
georgeh marked this conversation as resolved.
Show resolved Hide resolved

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