Skip to content

Commit ea5ffa4

Browse files
committed
Update js routes helpers
1 parent 4653e18 commit ea5ffa4

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

app/frontend/routes/index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file Generated by js-routes 2.3.5. Based on Rails 8.1.1 routes of ReactStarterKit::Application.
2+
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.1 routes of ReactStarterKit::Application.
33
* @version 743c630cafd479b5d9ad42a7803e8be1fdeb9448419ce21d215b267e2b0ae749
44
* @see https://github.com/railsware/js-routes
55
*/
@@ -67,6 +67,7 @@ declare type ModuleType = "CJS" | "AMD" | "UMD" | "ESM" | "DTS" | "NIL";
6767
declare const RubyVariables: {
6868
PREFIX: string;
6969
DEPRECATED_FALSE_PARAMETER_BEHAVIOR: boolean;
70+
DEPRECATED_NIL_QUERY_PARAMETER_BEHAVIOR: boolean;
7071
SPECIAL_OPTIONS_KEY: string;
7172
DEFAULT_URL_OPTIONS: RouteParameters;
7273
SERIALIZER: Serializer;

app/frontend/routes/index.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @file Generated by js-routes 2.3.5. Based on Rails 8.1.1 routes of ReactStarterKit::Application.
2+
* @file Generated by js-routes 2.3.6. Based on Rails 8.1.1 routes of ReactStarterKit::Application.
33
* @version 743c630cafd479b5d9ad42a7803e8be1fdeb9448419ce21d215b267e2b0ae749
44
* @see https://github.com/railsware/js-routes
55
*/
@@ -127,9 +127,6 @@ const __jsr = (
127127
};
128128
}
129129
default_serializer(value, prefix) {
130-
if (this.is_nullable(value)) {
131-
return "";
132-
}
133130
if (!prefix && !this.is_object(value)) {
134131
throw new Error("Url parameters should be a javascript hash");
135132
}
@@ -145,21 +142,22 @@ const __jsr = (
145142
if (!hasProp(value, key))
146143
continue;
147144
let prop = value[key];
148-
if (this.is_nullable(prop) && prefix) {
149-
prop = "";
145+
if (prefix) {
146+
key = prefix + "[" + key + "]";
150147
}
151-
if (this.is_not_nullable(prop)) {
152-
if (prefix) {
153-
key = prefix + "[" + key + "]";
154-
}
155-
result.push(this.default_serializer(prop, key));
148+
const subvalue = this.default_serializer(prop, key);
149+
if (subvalue.length) {
150+
result.push(subvalue);
156151
}
157152
}
158153
}
159154
else {
160-
if (this.is_not_nullable(value)) {
161-
result.push(encodeURIComponent(prefix) + "=" + encodeURIComponent("" + value));
162-
}
155+
result.push(this.is_not_nullable(value) ||
156+
false
157+
? encodeURIComponent(prefix) +
158+
"=" +
159+
encodeURIComponent("" + (value !== null && value !== void 0 ? value : ""))
160+
: encodeURIComponent(prefix));
163161
}
164162
return result.join("&");
165163
}

0 commit comments

Comments
 (0)