From 90b39f2f05ba11c5bc94514a04b40c48e4f755ea Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 22 Jan 2023 12:25:15 -0800 Subject: [PATCH] Implement URLSearchParams size getter In preparation for https://github.com/whatwg/url/pull/734 (this shouldn't land until that spec change lands) --- src/workerd/api/url-standard.h | 3 +++ src/workerd/api/url.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/workerd/api/url-standard.h b/src/workerd/api/url-standard.h index ffae854cfbb..fe69206a591 100644 --- a/src/workerd/api/url-standard.h +++ b/src/workerd/api/url-standard.h @@ -126,7 +126,10 @@ class URLSearchParams: public jsg::Object { jsg::UsvString toString(); + inline uint getSize() { return list.size(); } + JSG_RESOURCE_TYPE(URLSearchParams) { + JSG_READONLY_PROTOTYPE_PROPERTY(size, getSize); JSG_METHOD(append); JSG_METHOD_NAMED(delete, delete_); JSG_METHOD(get); diff --git a/src/workerd/api/url.h b/src/workerd/api/url.h index db757e826d3..19418bc858a 100644 --- a/src/workerd/api/url.h +++ b/src/workerd/api/url.h @@ -174,7 +174,10 @@ class URLSearchParams: public jsg::Object { kj::String toString(); + inline uint getSize() { return url->query.size(); } + JSG_RESOURCE_TYPE(URLSearchParams, CompatibilityFlags::Reader flags) { + JSG_READONLY_PROTOTYPE_PROPERTY(size, getSize); JSG_METHOD(append); JSG_METHOD_NAMED(delete, delete_); JSG_METHOD(get);