Skip to content

Commit 8fcd58c

Browse files
authored
refactor: normalize has_credentials method name (#333)
1 parent 70f7628 commit 8fcd58c

File tree

8 files changed

+16
-19
lines changed

8 files changed

+16
-19
lines changed

include/ada/url-inl.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#endif // ADA_REGULAR_VISUAL_STUDIO
1717

1818
namespace ada {
19-
[[nodiscard]] ada_really_inline bool url::includes_credentials()
20-
const noexcept {
19+
[[nodiscard]] ada_really_inline bool url::has_credentials() const noexcept {
2120
return !username.empty() || !password.empty();
2221
}
2322
[[nodiscard]] inline bool url::cannot_have_credentials_or_port() const {
@@ -53,7 +52,7 @@ size_t url::get_pathname_length() const noexcept { return path.size(); }
5352
// 2 characters for "//" and 1 character for starting index
5453
out.host_start = out.protocol_end + 2;
5554

56-
if (includes_credentials()) {
55+
if (has_credentials()) {
5756
out.username_end = uint32_t(out.host_start + username.size());
5857

5958
out.host_start += uint32_t(username.size());
@@ -181,7 +180,7 @@ inline void url::copy_scheme(const ada::url &u) {
181180

182181
if (host.has_value()) {
183182
output += "//";
184-
if (includes_credentials()) {
183+
if (has_credentials()) {
185184
output += username;
186185
if (!password.empty()) {
187186
output += ":" + get_password();

include/ada/url.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ struct url : url_base {
323323
* A URL includes credentials if its username or password is not the empty
324324
* string.
325325
*/
326-
[[nodiscard]] ada_really_inline bool includes_credentials() const noexcept;
326+
[[nodiscard]] ada_really_inline bool has_credentials() const noexcept;
327327

328328
/**
329329
* @private

include/ada/url_aggregator-inl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,8 @@ inline bool url_aggregator::base_search_has_value() const {
716716
return components.search_start != url_components::omitted;
717717
}
718718

719-
ada_really_inline bool url_aggregator::includes_credentials() const noexcept {
720-
ada_log("url_aggregator::includes_credentials");
719+
ada_really_inline bool url_aggregator::has_credentials() const noexcept {
720+
ada_log("url_aggregator::has_credentials");
721721
return has_non_empty_username() || has_non_empty_password();
722722
}
723723

include/ada/url_aggregator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct url_aggregator : url_base {
156156
* A URL includes credentials if its username or password is not the empty
157157
* string.
158158
*/
159-
[[nodiscard]] ada_really_inline bool includes_credentials() const noexcept;
159+
[[nodiscard]] ada_really_inline bool has_credentials() const noexcept;
160160

161161
/**
162162
* @private

src/url-setters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ bool url::set_host_or_hostname(const std::string_view input) {
5050
// empty string, and either url includes credentials or url’s port is
5151
// non-null, return.
5252
else if (host_view.empty() &&
53-
(is_special() || includes_credentials() || port.has_value())) {
53+
(is_special() || has_credentials() || port.has_value())) {
5454
return false;
5555
}
5656

src/url.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {
342342

343343
// If url includes credentials or has a non-null port, and buffer is
344344
// "file", then return.
345-
if ((includes_credentials() || port.has_value()) &&
345+
if ((has_credentials() || port.has_value()) &&
346346
parsed_type == ada::scheme::type::FILE) {
347347
return true;
348348
}
@@ -387,7 +387,7 @@ ada_really_inline bool url::parse_scheme(const std::string_view input) {
387387

388388
// If url includes credentials or has a non-null port, and buffer is
389389
// "file", then return.
390-
if ((includes_credentials() || port.has_value()) && _buffer == "file") {
390+
if ((has_credentials() || port.has_value()) && _buffer == "file") {
391391
return true;
392392
}
393393

@@ -539,7 +539,7 @@ std::string url::to_string() const {
539539
answer.append("\t\"protocol\":\"");
540540
helpers::encode_json(get_protocol(), back);
541541
answer.append("\",\n");
542-
if (includes_credentials()) {
542+
if (has_credentials()) {
543543
answer.append("\t\"username\":\"");
544544
helpers::encode_json(username, back);
545545
answer.append("\",\n");

src/url_aggregator.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ template <bool has_state_override>
3838

3939
// If url includes credentials or has a non-null port, and buffer is
4040
// "file", then return.
41-
if ((includes_credentials() ||
42-
components.port != url_components::omitted) &&
41+
if ((has_credentials() || components.port != url_components::omitted) &&
4342
parsed_type == ada::scheme::type::FILE) {
4443
return true;
4544
}
@@ -82,8 +81,7 @@ template <bool has_state_override>
8281

8382
// If url includes credentials or has a non-null port, and buffer is
8483
// "file", then return.
85-
if ((includes_credentials() ||
86-
components.port != url_components::omitted) &&
84+
if ((has_credentials() || components.port != url_components::omitted) &&
8785
_buffer == "file") {
8886
return true;
8987
}
@@ -570,7 +568,7 @@ bool url_aggregator::set_host_or_hostname(const std::string_view input) {
570568
// empty string, and either url includes credentials or url’s port is
571569
// non-null, return.
572570
else if (host_view.empty() &&
573-
(is_special() || includes_credentials() ||
571+
(is_special() || has_credentials() ||
574572
components.port != url_components::omitted)) {
575573
return false;
576574
}
@@ -783,7 +781,7 @@ std::string ada::url_aggregator::to_string() const {
783781
helpers::encode_json(get_protocol(), back);
784782
answer.append("\",\n");
785783

786-
if (includes_credentials()) {
784+
if (has_credentials()) {
787785
answer.append("\t\"username\":\"");
788786
helpers::encode_json(get_username(), back);
789787
answer.append("\",\n");

tests/url_components.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ bool urltestdata_encoding(const char* source) {
149149
}
150150

151151
size_t host_start = out.host_start;
152-
if (url.includes_credentials()) {
152+
if (url.has_credentials()) {
153153
TEST_ASSERT(url.get_href()[out.host_start], '@',
154154
"hostname should start with @");
155155
host_start++;

0 commit comments

Comments
 (0)