Skip to content
Closed
Show file tree
Hide file tree
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
Fix TypeError in node 0.11.14: "Object.keys called on non-object"
  • Loading branch information
atomantic committed Oct 13, 2014
commit 11d6be5697fa61857b87fef3749c65adf38439fc
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