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

refactor(schemes): convert unused capture group to non-capture group #66

Merged
merged 1 commit into from
Jul 8, 2023

Conversation

Fdawgs
Copy link
Member

@Fdawgs Fdawgs commented Jul 8, 2023

Third capture group is never used anywhere, so it's being added to the returned array from .match() for no reason:

fast-uri/lib/schemes.js

Lines 81 to 98 in 8b0e018

const matches = urnComponents.path.match(URN_REG)
if (matches) {
const scheme = options.scheme || urnComponents.scheme || 'urn'
urnComponents.nid = matches[1].toLowerCase()
urnComponents.nss = matches[2]
const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`
const schemeHandler = SCHEMES[urnScheme]
urnComponents.path = undefined
if (schemeHandler) {
urnComponents = schemeHandler.parse(urnComponents, options)
}
} else {
urnComponents.error = urnComponents.error || 'URN can not be parsed.'
}
return urnComponents
}

Checklist

Copy link
Member

@zekth zekth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

@Fdawgs Fdawgs merged commit b119a8c into main Jul 8, 2023
23 checks passed
@Fdawgs Fdawgs deleted the refactor/regex branch July 8, 2023 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants