Skip to content

Commit

Permalink
Fix TypeError in node 0.11.14: "Object.keys called on non-object"
Browse files Browse the repository at this point in the history
  • Loading branch information
atomantic committed Oct 13, 2014
1 parent 22bb426 commit 11d6be5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/util/urltils.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ module.exports = {
parseParameters : function parseParameters(requestURL) {
var parsed = url.parse(requestURL, true)
, parameters = {}


if (parsed.search !== '') {

if (parsed.search) {
Object.keys(parsed.query).forEach(function cb_forEach(key) {
if (parsed.query[key] === '' && parsed.path.indexOf(key + '=') < 0) {
parameters[key] = true
Expand Down
18 changes: 16 additions & 2 deletions test/unit/urltils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var path = require('path')
, chai = require('chai')
, expect = chai.expect
, urltils = require('../../lib/util/urltils.js')


describe("NR URL utilities", function () {
describe("scrubbing URLs", function () {
Expand All @@ -13,6 +13,20 @@ describe("NR URL utilities", function () {
})
})

describe("parsing parameters", function () {
it("should find empty object of params in url lacking query", function () {
expect(urltils.parseParameters('/favicon.ico')).deep.equal({});
})

it("should find v param in url containing ?v with no value", function () {
expect(urltils.parseParameters('/status?v')).deep.equal({v:true});
})

it("should find v param with value in url containing ?v=1", function () {
expect(urltils.parseParameters('/status?v=1')).deep.equal({v:'1'});
})
})

describe("determining whether an HTTP status code is an error", function () {
var config = {error_collector : {ignore_status_codes : []}}

Expand Down Expand Up @@ -129,7 +143,7 @@ describe("NR URL utilities", function () {
var config
, source
, dest


beforeEach(function () {
config = {
Expand Down

0 comments on commit 11d6be5

Please sign in to comment.