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

files.included is not an array, keys might not be an index #2580

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ var createKarmaMiddleware = function (
var scriptTags = []
var scriptUrls = []
for (var i in files.included) {
if (!files.included.hasOwnProperty(i)) {
// files.included is not an array
// keys might not be an index
break
Copy link

@wermanoid wermanoid Feb 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it good idea to break loop?
In case if that strange file without path appears not at the end of "files.included" array, it will broke everything...
Maybe it's better to change 'break' to 'continue'?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest just using .forEach like this:

if (files.included.forEach && typeof files.included.forEach === 'function') {
  files.included.forEach(function (file) {...})
}

}
var file = files.included[i]
var filePath = file.path
var fileExt = path.extname(filePath)
Expand Down