rails / request.js

MIT License
389 stars 28 forks source link

split is not a function #38

Closed hms closed 2 years ago

hms commented 2 years ago

At the serious risk of demonstrating just how much of the JS world I don't understand...

I'm getting a "split is not a function" error in fetch_request.js at line 117. From my playing around, shouldn't that line require a .href before calling the split()? return this.originalUrl.href.split('?')[0] ....

in order to extra a splittable string from the URL object?

If this is correct, then line 98 also needs the correction.

marcelolx commented 2 years ago

I suppose that you are passing a URL object as URL, right? In that case, yeah we should call href, but as it is today it isn't wrong since if you pass a string as URL it won't respond to href.

Could you provide an example where do you need to pass a URL object instead of just the URL string?

Edit: We can change to support both, URL as a string and as an Object, but I would like the use case before making any decision

excid3 commented 2 years ago

It probably wouldn't hurt to cast the url toString in the constructor so it can support both.

hms commented 2 years ago

As expected it was me.

I was passing FetchRequest a URL object. I've changed my code to pass a string, which I believe, is the expected argument type.

As usual, thank you @excid3 for jumping in so quickly with the correct observation and pointing me in the right direction.

excid3 commented 2 years ago

Just submitted a PR that should address this nicely.

marcelolx commented 2 years ago

Thanks Chris!