Skip to content

Commit

Permalink
readme: show get/getAll results for non-present key
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed May 3, 2024
1 parent 19324fa commit 803d5e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ uri.query // → 'q=x&q='
uri.fragment // → 'hash'
uri.queryParams.get('q') // → 'x'
uri.queryParams.getAll('q') // → ['x', '']
uri.queryParams.get('not-present') // → null
uri.queryParams.getAll('not-present') // → []
// also available: href, origin, authority, userinfo, username, password, tld

// relative path (not starting from root /)
Expand Down Expand Up @@ -105,14 +107,15 @@ uri.protocol // → 'mailto'
uri.username // → ''
uri.hostname // → ''
uri.pathname // → '[email protected],[email protected]'
uri.queryParams.get('subject') // → 'Hey'
uri.query // → 'subject=Hey&body=Sign%20me%20up!'
uri.queryParams.get('body') // → 'Sign me up!'

// mailto in friendly mode
uri = parseUri('mailto:[email protected]?subject=Hey', 'friendly');
uri.protocol // → 'mailto'
uri.username // → 'me'
uri.hostname // → 'my.com'
uri.queryParams.get('subject') // → 'Hey'
uri.pathname // → ''

/* Also supports e.g.:
- https://[2001:db8:85a3::7334%en1]/ipv6-with-zone-identifier
Expand Down
2 changes: 1 addition & 1 deletion spec/spec-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('queryParams', () => {
expect(queryParams.size).toBe(1);
});

it('should allow ? in query keys and values', () => {
it('should allow ? in key names and values', () => {
expect(parseUri('??q=x').queryParams.get('?q')).toBe('x');
expect(parseUri('?q?=x').queryParams.get('q?')).toBe('x');
expect(parseUri('?q=?').queryParams.get('q')).toBe('?');
Expand Down

0 comments on commit 803d5e0

Please sign in to comment.