Skip to content

Commit

Permalink
Optimize path start state
Browse files Browse the repository at this point in the history
This adds a fast path for URLs like `ws://h`, `ws://h\` and `ws://h/`
that parse to `ws://h/`.
  • Loading branch information
rmisev committed Jan 7, 2025
1 parent cc12906 commit 20fde67
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions include/upa/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,14 @@ inline validation_errc url_parser::url_parse(url_serializer& urls, const CharT*
++pointer;
}
}
if (pointer == last) {
// Optimization:
// "ws://h", "ws://h\" and "ws://h/" parses to "ws://h/"
// See: https://github.com/whatwg/url/pull/847
urls.append_empty_path_segment();
urls.commit_path();
return validation_errc::ok;
}
state = path_state;
} else if (pointer != last) {
if (!state_override) {
Expand Down

0 comments on commit 20fde67

Please sign in to comment.