diff --git a/src/workerd/api/url-standard.c++ b/src/workerd/api/url-standard.c++ index ad885e9f031..fe694941f66 100644 --- a/src/workerd/api/url-standard.c++ +++ b/src/workerd/api/url-standard.c++ @@ -1943,7 +1943,16 @@ void URLSearchParams::append(jsg::UsvString name, jsg::UsvString value) { update(); } -void URLSearchParams::delete_(jsg::UsvString name) { +void URLSearchParams::delete_(jsg::UsvString name, jsg::Optional value) { + KJ_IF_MAYBE(v, value) { + // The WHATWG recently added new arguments to the delete() and has() methods. + // We need to determine if adding those will break anyone if they are added + // without a compat flag. For now, we're just logging so we can know for sure. + // If we get this warning even once in production we'll have to introduce the + // new arguments behind a compat flag. + // https://github.com/whatwg/url/pull/735 + LOG_WARNING_ONCE("URLSearchParams.prototype.delete() called with a second argument."); + } auto pivot = std::remove_if(list.begin(), list.end(), [&name](auto& kv) { return kv.name == name; }); list.truncate(pivot - list.begin()); @@ -1965,7 +1974,16 @@ kj::Array URLSearchParams::getAll(jsg::UsvString name) { return result.releaseAsArray(); } -bool URLSearchParams::has(jsg::UsvString name) { +bool URLSearchParams::has(jsg::UsvString name, jsg::Optional value) { + KJ_IF_MAYBE(v, value) { + // The WHATWG recently added new arguments to the delete() and has() methods. + // We need to determine if adding those will break anyone if they are added + // without a compat flag. For now, we're just logging so we can know for sure. + // If we get this warning even once in production we'll have to introduce the + // new arguments behind a compat flag. + // https://github.com/whatwg/url/pull/735 + LOG_WARNING_ONCE("URLSearchParams.prototype.has() called with a second argument."); + } for (auto& entry : list) { if (entry.name == name) return true; } diff --git a/src/workerd/api/url-standard.h b/src/workerd/api/url-standard.h index 5ebb9a3344d..25c0f2bd576 100644 --- a/src/workerd/api/url-standard.h +++ b/src/workerd/api/url-standard.h @@ -96,10 +96,10 @@ class URLSearchParams: public jsg::Object { } void append(jsg::UsvString name, jsg::UsvString value); - void delete_(jsg::UsvString name); + void delete_(jsg::UsvString name, jsg::Optional value); kj::Maybe get(jsg::UsvString name); kj::Array getAll(jsg::UsvString name); - bool has(jsg::UsvString name); + bool has(jsg::UsvString name, jsg::Optional value); void set(jsg::UsvString name, jsg::UsvString value); void sort();