-
-
Notifications
You must be signed in to change notification settings - Fork 687
fix: accept URL origin in Agent #892
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
Conversation
|
I wonder if it would be better to use |
Codecov Report
@@ Coverage Diff @@
## main #892 +/- ##
=======================================
Coverage 99.62% 99.62%
=======================================
Files 26 26
Lines 2126 2127 +1
=======================================
+ Hits 2118 2119 +1
Misses 8 8
Continue to review full report at Codecov.
|
|
Line 161 in aebbb5d
is unsafe because: Lines 75 to 76 in aebbb5d
Lines 58 to 72 in aebbb5d
meaning: it does not return |
Make |
lib/agent.js
Outdated
| if (typeof opts.origin !== 'string' || opts.origin === '') { | ||
| throw new InvalidArgumentError('opts.origin must be a non-empty string.') | ||
| } | ||
| const { origin } = util.parseOrigin(opts.origin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little concerned about the performance implications. Is it negligable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing URLs is slow, we should not be creating a fresh URL instance every time if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
origin is just used as a key here so we don't actually need to validate it.
this[kFactory](origin, this[kOptions]) should do the validation already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let origin
if (opts.origin && (typeof opts.origin === 'string' || opts.origin instanceof URL)) {
origin = String(opts.origin)
} else {
throw new InvalidArgumentError('opts.origin must be a non-empty string or URL.')
}
Would be great if you did before/after. Also I don't think the benchmarks test |
You could let |
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
* fix: accept URL origin in Agent * fix: lint * fixup Co-authored-by: Robert Nagy <ronagy@icloud.com>
Fixes #889