-
Notifications
You must be signed in to change notification settings - Fork 30k
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
url: introduce native URL class for internal use #11801
Conversation
Can you add some gtests for this new API? |
src/node_url.cc
Outdated
|
||
inline void SetFlag(struct url_data* url, enum url_flags flag) { | ||
url->flags |= flag; | ||
} |
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.
Maybe it’s just me, but I’d probably find it more readable if these methods were just inlined
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.
hmm... I guess... I prefer the inlined methods personally but I can change it up
src/node_url.h
Outdated
const size_t len, | ||
enum url_parse_state state_override, | ||
struct url_data* url, | ||
struct url_data* base, |
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.
This can probably be const struct url_data* base
?
src/node_url.h
Outdated
Parse(input, len, kUnknownState, &context_, nullptr, false); | ||
} | ||
|
||
URL(const char* input, const size_t len, URL* base) { |
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.
Likewise, const URL* base
?
src/node_url.h
Outdated
|
||
std::string protocol() { | ||
return context_.scheme; | ||
} |
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 think there’s no reason to not make these methods return const references, i.e. const std::string& protocol() const { … }
(except path()
)?
@TimothyGu ... yep, I intend to, just ran out of time on Friday and wanted to get this out so that @bmeck had something he could start working with. Will look at adding tests on Monday. |
@addaleax ... addressed your feedback. @TimothyGu ... adding a gtest is going to be more involved. I'd like to add that later in a separate PR so that I can get this landed for @bmeck to use. |
CI is 🍏 |
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
(And yeah, this is definitely more readable. Thank you!)
@TimothyGu ... once #11956 lands I will be able to get tests added for the native class. |
Adds a URL native class for use within the node.js c/c++ code. This is primarily intended to be used by the eventual ES6 modules implementation but can be used generally wherever URL parsing within the c/c++ may be necessary. ```c URL url1("http://example.org"); URL url2("foo", "http://example.org/bar"); URL url3("baz", &url2); ``` While we're at it, reduce reliance on macros to simplify impl.
Adds a URL native class for use within the node.js c/c++ code. This is primarily intended to be used by the eventual ES6 modules implementation but can be used generally wherever URL parsing within the c/c++ may be necessary. ```c URL url1("http://example.org"); URL url2("foo", "http://example.org/bar"); URL url3("baz", &url2); ``` While we're at it, reduce reliance on macros to simplify impl. PR-URL: #11801 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Landed in e26b6c6 |
Adds a URL native class for use within the node.js c/c++ code. This is primarily intended to be used by the eventual ES6 modules implementation but can be used generally wherever URL parsing within the c/c++ may be necessary. ```c URL url1("http://example.org"); URL url2("foo", "http://example.org/bar"); URL url3("baz", &url2); ``` While we're at it, reduce reliance on macros to simplify impl. PR-URL: #11801 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Notable changes: * buffer: - do not segfault on out-of-range index (Timothy Gu) #11927 * crypto: - Fix memory leak if certificate is revoked (Tom Atkinson) #12089 * deps: * upgrade npm to 4.2.0 (Kat Marchán) #11389 * fix async await desugaring in V8 (Michaël Zasso) #12004 * readline: - add option to stop duplicates in history (Danny Nemer) #2982 * src: - add native URL class (James M Snell) #11801 PR-URL: #12104
Notable changes: * buffer: - do not segfault on out-of-range index (Timothy Gu) #11927 * crypto: - Fix memory leak if certificate is revoked (Tom Atkinson) #12089 * deps: * upgrade npm to 4.2.0 (Kat Marchán) #11389 * fix async await desugaring in V8 (Michaël Zasso) #12004 * readline: - add option to stop duplicates in history (Danny Nemer) #2982 * src: - add native URL class (James M Snell) #11801 PR-URL: #12104
Notable changes: * buffer: - do not segfault on out-of-range index (Timothy Gu) nodejs/node#11927 * crypto: - Fix memory leak if certificate is revoked (Tom Atkinson) nodejs/node#12089 * deps: * upgrade npm to 4.2.0 (Kat Marchán) nodejs/node#11389 * fix async await desugaring in V8 (Michaël Zasso) nodejs/node#12004 * readline: - add option to stop duplicates in history (Danny Nemer) nodejs/node#2982 * src: - add native URL class (James M Snell) nodejs/node#11801 PR-URL: nodejs/node#12104 Signed-off-by: Ilkka Myller <ilkka.myller@nodefield.com>
Provides a native URL class that uses the WHATWG URL algorithm.
This is intended primarily to support the ES6 modules implementation work (which will need WHATWG URL processing).
/cc @bmeck
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
url