diff --git a/lib/js_rails_routes/language/javascript.rb b/lib/js_rails_routes/language/javascript.rb index 24553a2..dba1341 100644 --- a/lib/js_rails_routes/language/javascript.rb +++ b/lib/js_rails_routes/language/javascript.rb @@ -9,7 +9,7 @@ class JavaScript < Base PROCESS_FUNC = <<~JAVASCRIPT function process(route, params, keys) { var query = []; - for (var param in params) if (params.hasOwnProperty(param)) { + for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) { if (keys.indexOf(param) === -1) { query.push(param + "=" + encodeURIComponent(params[param])); } diff --git a/lib/js_rails_routes/language/typescript.rb b/lib/js_rails_routes/language/typescript.rb index bd38b09..c0dfc6d 100644 --- a/lib/js_rails_routes/language/typescript.rb +++ b/lib/js_rails_routes/language/typescript.rb @@ -12,7 +12,7 @@ class TypeScript < JavaScript function process(route: string, params: Record | undefined, keys: string[]): string { if (!params) return route var query: string[] = []; - for (var param in params) if (params.hasOwnProperty(param)) { + for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) { if (keys.indexOf(param) === -1) { query.push(param + "=" + encodeURIComponent(params[param].toString())); } diff --git a/spec/js_rails_routes/language/javascript_spec.rb b/spec/js_rails_routes/language/javascript_spec.rb index 24793eb..5ee4dd3 100644 --- a/spec/js_rails_routes/language/javascript_spec.rb +++ b/spec/js_rails_routes/language/javascript_spec.rb @@ -12,7 +12,7 @@ expect(subject).to eq <<~JAVASCRIPT function process(route, params, keys) { var query = []; - for (var param in params) if (params.hasOwnProperty(param)) { + for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) { if (keys.indexOf(param) === -1) { query.push(param + "=" + encodeURIComponent(params[param])); } diff --git a/spec/js_rails_routes/language/typescript_spec.rb b/spec/js_rails_routes/language/typescript_spec.rb index 163ffc4..0155050 100644 --- a/spec/js_rails_routes/language/typescript_spec.rb +++ b/spec/js_rails_routes/language/typescript_spec.rb @@ -15,7 +15,7 @@ function process(route: string, params: Record | undefined, keys: string[]): string { if (!params) return route var query: string[] = []; - for (var param in params) if (params.hasOwnProperty(param)) { + for (var param in params) if (Object.prototype.hasOwnProperty.call(params, param)) { if (keys.indexOf(param) === -1) { query.push(param + "=" + encodeURIComponent(params[param].toString())); }