Skip to content

Commit 27b4215

Browse files
committed
Implement URLSearchParams size getter
In preparation for whatwg/url#734 (this shouldn't land until that spec change lands)
1 parent c336d40 commit 27b4215

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/workerd/api/url-standard.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ class URLSearchParams: public jsg::Object {
123123

124124
jsg::UsvString toString();
125125

126+
inline uint getSize() { return list.size(); }
127+
126128
JSG_RESOURCE_TYPE(URLSearchParams) {
129+
JSG_READONLY_PROTOTYPE_PROPERTY(size, getSize);
127130
JSG_METHOD(append);
128131
JSG_METHOD_NAMED(delete, delete_);
129132
JSG_METHOD(get);

src/workerd/api/url.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ class URLSearchParams: public jsg::Object {
170170

171171
kj::String toString();
172172

173+
inline uint getSize() { return url->query.size(); }
174+
173175
JSG_RESOURCE_TYPE(URLSearchParams, CompatibilityFlags::Reader flags) {
176+
JSG_READONLY_PROTOTYPE_PROPERTY(size, getSize);
174177
JSG_METHOD(append);
175178
JSG_METHOD_NAMED(delete, delete_);
176179
JSG_METHOD(get);

0 commit comments

Comments
 (0)