Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object.split problem in requirejs #1415

Open
ORESoftware opened this issue Aug 30, 2015 · 4 comments
Open

object.split problem in requirejs #1415

ORESoftware opened this issue Aug 30, 2015 · 4 comments

Comments

@ORESoftware
Copy link

I found a weird bug on line 276 of require.js, in the function called "normalize"

the problem was that 'name' was an object in the code (typeof name === 'object') and split was called on that object which causes problems

if (name) {
    name = name.split('/');  //error here: "name.split is not a function"

to generalize, when you call

var obj = {};
obj.split('') // will throw "obj.split is not a function"

so this solves the problem

name = String(name).split('/');

but I believe you might want to examine require.js to see why an object ended up in the normalize function in your codebase

thanks

@ORESoftware
Copy link
Author

I mean, my usage of the library put the object there somehow, but it seems like maybe something could be a little off

@jrburke
Copy link
Member

jrburke commented Aug 31, 2015

It would be good to have a use case or description on how this condition occurred, to know what entry point the non-string object came into the require() or define() APIs to get to that condition. It is costly to file size to put type checks in every function, ideally the issues are caught at the public entry points.

@ORESoftware
Copy link
Author

sure I understand, I will give you more context in the next 48 hours

@rjgotten
Copy link

rjgotten commented Oct 7, 2015

It would be good to have a use case or description on how this condition occurred

A trailing comma in the dependency array is enough to trigger this problem. I've had it happen numerous times myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants