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');