Skip to content

Commit

Permalink
Remove hasAuth via destructuring assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed May 19, 2024
1 parent 5a9aa17 commit b0e1ad8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/parseuri.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ list of second-level domains that should be treated as part of the top-level dom
function parseUri(uri, mode = 'default') {
uri = uri.trim();
const {groups} = cache.parser[mode].exec(uri);
const result = {
const {hasAuth, ...result} = {
href: uri,
...groups,
// URNs: if we have an authority (contained in `hasAuth`), keep dir/file, else remove because
// they don't apply. `hasAuth` indicates participation in the match, but it could be empty
...(groups.protocol && groups.hasAuth == null ? blankUrnProps : null),
};
delete result.hasAuth;
// replace `undefined` for non-participating capturing groups
Object.keys(result).forEach(key => result[key] ??= '');
return Object.assign(result, {
Expand Down

0 comments on commit b0e1ad8

Please sign in to comment.