Skip to content

Commit b404e17

Browse files
committed
Make dropShevronSuffix more explicit about npos handling
The previous implementation relied on substr(0, npos) returning the entire string, which works but is subtle. This change makes the behavior explicit by checking for npos and returning the original string unchanged when no chevron is found.
1 parent b428417 commit b404e17

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libutil/url.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ std::regex revRegex(revRegexS, std::regex::ECMAScript);
2121
static std::string_view dropShevronSuffix(std::string_view url)
2222
{
2323
auto shevron = url.rfind("^");
24+
if (shevron == std::string_view::npos)
25+
return url;
2426
return url.substr(0, shevron);
2527
}
2628

0 commit comments

Comments
 (0)