From f792d3185f1853f3aa506a60878042f7c16e31ab Mon Sep 17 00:00:00 2001 From: fardog Date: Fri, 7 Aug 2015 13:57:46 -0700 Subject: [PATCH] Don't require a user in the DSN --- src/raven.js | 2 +- test/raven.test.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/raven.js b/src/raven.js index f64efe8e78e8..c9489f0a6e86 100644 --- a/src/raven.js +++ b/src/raven.js @@ -423,7 +423,7 @@ function triggerEvent(eventType, options) { } var dsnKeys = 'source protocol user pass host port path'.split(' '), - dsnPattern = /^(?:(\w+):)?\/\/(\w+)(:\w+)?@([\w\.-]+)(?::(\d+))?(\/.*)/; + dsnPattern = /^(?:(\w+):)?\/\/(?:(\w+)(:\w+)?@)?([\w\.-]+)(?::(\d+))?(\/.*)/; function RavenConfigError(message) { this.name = 'RavenConfigError'; diff --git a/test/raven.test.js b/test/raven.test.js index 5e883f32d385..230d80ffdce6 100644 --- a/test/raven.test.js +++ b/test/raven.test.js @@ -359,6 +359,15 @@ describe('globals', function() { assert.strictEqual(pieces.host, 'matt-robenolt.com'); }); + it('should parse domain without user', function() { + var pieces = parseDSN('http://matt-robenolt.com/1'); + assert.strictEqual(pieces.protocol, 'http'); + assert.strictEqual(pieces.user, ''); + assert.strictEqual(pieces.port, ''); + assert.strictEqual(pieces.path, '/1'); + assert.strictEqual(pieces.host, 'matt-robenolt.com'); + }); + it('should raise a RavenConfigError when setting a password', function() { try { parseDSN('http://user:pass@example.com/2');