Skip to content

Commit 7341f7d

Browse files
committed
Assert that canonicalizePathname, canonicalizeSearch, and canonicalizeHash cannot fail
https://bugs.webkit.org/show_bug.cgi?id=290113 Reviewed by Youenn Fablet. Although the specification seems to assume these operations can fail, they cannot. * Source/WebCore/Modules/url-pattern/URLPatternCanonical.cpp: (WebCore::canonicalizePathname): (WebCore::canonicalizeSearch): (WebCore::canonicalizeHash): Canonical link: https://commits.webkit.org/292579@main
1 parent 2db0901 commit 7341f7d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

Source/WebCore/Modules/url-pattern/URLPatternCanonical.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ ExceptionOr<String> canonicalizePathname(StringView pathnameValue)
196196
// FIXME: Set state override to State::PathStart after URLParser supports state override.
197197
URL dummyURL(dummyURLCharacters);
198198
dummyURL.setPath(maybeAddSlashPrefix);
199-
200-
if (!dummyURL.isValid())
201-
return Exception { ExceptionCode::TypeError, "Invalid input to canonicalize a URL path string."_s };
199+
ASSERT(dummyURL.isValid());
202200

203201
auto result = dummyURL.path();
204202
if (!hasLeadingSlash)
@@ -235,9 +233,7 @@ ExceptionOr<String> canonicalizeSearch(StringView value, BaseURLStringType value
235233

236234
URL dummyURL(dummyURLCharacters);
237235
dummyURL.setQuery(strippedValue);
238-
239-
if (!dummyURL.isValid())
240-
return Exception { ExceptionCode::TypeError, "Invalid input to canonicalize a URL search string."_s };
236+
ASSERT(dummyURL.isValid());
241237

242238
return dummyURL.query().toString();
243239
}
@@ -255,9 +251,7 @@ ExceptionOr<String> canonicalizeHash(StringView value, BaseURLStringType valueTy
255251

256252
URL dummyURL(dummyURLCharacters);
257253
dummyURL.setFragmentIdentifier(strippedValue);
258-
259-
if (!dummyURL.isValid())
260-
return Exception { ExceptionCode::TypeError, "Invalid input to canonicalize a URL hash string."_s };
254+
ASSERT(dummyURL.isValid());
261255

262256
return dummyURL.fragmentIdentifier().toString();
263257
}

0 commit comments

Comments
 (0)