railsware / js-routes

Brings Rails named routes to javascript
http://railsware.github.io/js-routes/
MIT License
1.61k stars 151 forks source link

Cannot convert object to primitive value #272

Closed pustovalov closed 3 years ago

pustovalov commented 3 years ago

Hey,

const params = queryString.parse('?q=advocate@example.com')

Routes.account_path(1, params)

1.4.14

"/account/1?q=advocate%40example.com"

2.0.0

routes.js:408 Uncaught TypeError: Cannot convert object to primitive value
    at UtilsClass.is_object (routes.js:408)
    at UtilsClass.extract_options (routes.js:126)
    at UtilsClass.partition_parameters (routes.js:171)
    at UtilsClass.build_route (routes.js:220)
    at Module.result (routes.js:358)
    at <anonymous>:1:8

Cause of error:

The returned object is created with Object.create(null) and thus does not have a prototype.

https://github.com/sindresorhus/query-string#parsestring-options

Are you planning to fix it or need to use workaround?

bogdan commented 3 years ago

I think it is a bug. I will fix it in a few days.

bogdan commented 3 years ago

Version 2.0.1 👍

pustovalov commented 3 years ago

Thx, works well