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

Please can you use strict mode to write this plugin #3

Open
drnkwati opened this issue Dec 20, 2017 · 2 comments
Open

Please can you use strict mode to write this plugin #3

drnkwati opened this issue Dec 20, 2017 · 2 comments

Comments

@drnkwati
Copy link

Using strict mode will prevent run-time errors in most modern JavaScript environment
Please run a build with strict mode enabled
spercifically the errors came from you usage of split

parameters[i].split('=')
this throws errors in console during runtime
thanks

@hustcc
Copy link
Owner

hustcc commented Dec 20, 2017

If some idea, give me a pr for help?

@drnkwati
Copy link
Author

I fixed this line and it worked perfectly.
Type check string before attempting to split
You can update the master branch

//从url中解析配置信息
function parseUrlOptions(url) {
var opts = {},
parameters = url.split('&'),
k_v;
//
for (var i in parameters) {
if (typeof parameters[i] == 'string') {
k_v = parameters[i].split('=');
try {
opts[k_v[0]] = decodeURIComponent(k_v[1]);
} catch (e) {
opts[k_v[0]] = k_v[1];
}
}
}

    return opts;
}

I love this library
thanks

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

2 participants