Skip to content

Commit

Permalink
fix: Wrap url.parse to always return an object for query property
Browse files Browse the repository at this point in the history
Closes #1182
  • Loading branch information
nathanfaucett committed Sep 18, 2014
1 parent 709fe6d commit 72452e9
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@

var path = require('path');
var util = require('util');
var urlparse = require('url').parse;
var url = require('url');

var urlparse = function(urlStr) {
var urlObj = url.parse(urlStr, true);
urlObj.query = urlObj.query || {};
return urlObj;
};

var common = require('./common');

Expand All @@ -36,7 +42,7 @@ var filePathToUrlPath = function(filePath, basePath) {

var getXUACompatibleMetaElement = function(url) {
var tag = '';
var urlObj = urlparse(url, true);
var urlObj = urlparse(url);
if (urlObj.query['x-ua-compatible']) {
tag = '\n<meta http-equiv="X-UA-Compatible" content="' +
urlObj.query['x-ua-compatible'] + '"/>';
Expand All @@ -46,7 +52,7 @@ var getXUACompatibleMetaElement = function(url) {

var getXUACompatibleUrl = function(url) {
var value = '';
var urlObj = urlparse(url, true);
var urlObj = urlparse(url);
if (urlObj.query['x-ua-compatible']) {
value = '?x-ua-compatible=' + encodeURIComponent(urlObj.query['x-ua-compatible']);
}
Expand Down

0 comments on commit 72452e9

Please sign in to comment.