Skip to content

Commit 1506384

Browse files
bnoordhuisMylesBorins
authored andcommitted
src: fix windows-only build breakage
Commit af6af08 introduced a build error in a Windows-only code path in src/node_url.cc. Fix it by making the code a little nicer in general: const-ify the `input` parameter to `ToASCII()` and `ToUnicode()`. PR-URL: #15724 Refs: #15615 Refs: #15723 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 5630c8c commit 1506384

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/node_url.cc

+11-11
Original file line numberDiff line numberDiff line change
@@ -573,30 +573,30 @@ static inline int NormalizePort(std::string scheme, int p) {
573573
}
574574

575575
#if defined(NODE_HAVE_I18N_SUPPORT)
576-
static inline bool ToUnicode(std::string* input, std::string* output) {
576+
static inline bool ToUnicode(const std::string& input, std::string* output) {
577577
MaybeStackBuffer<char> buf;
578-
if (i18n::ToUnicode(&buf, input->c_str(), input->length()) < 0)
578+
if (i18n::ToUnicode(&buf, input.c_str(), input.length()) < 0)
579579
return false;
580580
output->assign(*buf, buf.length());
581581
return true;
582582
}
583583

584-
static inline bool ToASCII(std::string* input, std::string* output) {
584+
static inline bool ToASCII(const std::string& input, std::string* output) {
585585
MaybeStackBuffer<char> buf;
586-
if (i18n::ToASCII(&buf, input->c_str(), input->length()) < 0)
586+
if (i18n::ToASCII(&buf, input.c_str(), input.length()) < 0)
587587
return false;
588588
output->assign(*buf, buf.length());
589589
return true;
590590
}
591591
#else
592592
// Intentional non-ops if ICU is not present.
593-
static inline bool ToUnicode(std::string* input, std::string* output) {
594-
*output = *input;
593+
static inline bool ToUnicode(const std::string& input, std::string* output) {
594+
*output = input;
595595
return true;
596596
}
597597

598-
static inline bool ToASCII(std::string* input, std::string* output) {
599-
*output = *input;
598+
static inline bool ToASCII(const std::string& input, std::string* output) {
599+
*output = input;
600600
return true;
601601
}
602602
#endif
@@ -864,7 +864,7 @@ static url_host_type ParseHost(url_host* host,
864864
PercentDecode(input, length, &decoded);
865865

866866
// Then we have to punycode toASCII
867-
if (!ToASCII(&decoded, &decoded))
867+
if (!ToASCII(decoded, &decoded))
868868
goto end;
869869

870870
// If any of the following characters are still present, we have to fail
@@ -881,7 +881,7 @@ static url_host_type ParseHost(url_host* host,
881881
goto end;
882882

883883
// If the unicode flag is set, run the result through punycode ToUnicode
884-
if (unicode && !ToUnicode(&decoded, &decoded))
884+
if (unicode && !ToUnicode(decoded, &decoded))
885885
goto end;
886886

887887
// It's not an IPv4 or IPv6 address, it must be a domain
@@ -2124,7 +2124,7 @@ std::string URL::ToFilePath() const {
21242124
if ((context_.flags & URL_FLAGS_HAS_HOST) &&
21252125
context_.host.length() > 0) {
21262126
std::string unicode_host;
2127-
if (!ToUnicode(&context_.host, &unicode_host)) {
2127+
if (!ToUnicode(context_.host, &unicode_host)) {
21282128
return "";
21292129
}
21302130
return "\\\\" + unicode_host + decoded_path;

0 commit comments

Comments
 (0)