diff --git a/lib/sip-parser/parser.js b/lib/sip-parser/parser.js index c654ff3..3569397 100644 --- a/lib/sip-parser/parser.js +++ b/lib/sip-parser/parser.js @@ -224,7 +224,10 @@ function parseUri(s) { // eslint-disable-next-line max-len //const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?([\w\-\.]+)(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/; // eslint-disable-next-line max-len - const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?(?:(|(?:\[.*\])|(?:[0-9A-Za-z\-_]+\.)+[0-9A-Za-z\-_]+)|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/; + const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?(?:(|(?:\[.*\])|(?:[0-9A-Za-z\-_]+\.)*[0-9A-Za-z\-_]+)|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}))(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/; + // eslint-disable-next-line max-len + //const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?((?:[0-9A-Za-z\-_]+\.)?[0-9A-Za-z\-_]+|(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})|\[(?:[A-Fa-f0-9:]+)\])(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/; + const r = re.exec(s); diff --git a/test/unit-tests/parser.js b/test/unit-tests/parser.js index 93884df..84e5154 100644 --- a/test/unit-tests/parser.js +++ b/test/unit-tests/parser.js @@ -127,6 +127,13 @@ describe('Parser', function () { uri.user.should.eql('116751x0'); uri.scheme.should.eql('sips'); }); + it('should parse a sip uri with host part being simple label', function () { + var uri = parseUri('sip:116751@feature-server'); + uri.family.should.eql('ipv4'); + uri.host.should.eql('feature-server'); + uri.user.should.eql('116751'); + uri.scheme.should.eql('sip'); + }); it('should parse a multi-part header', function () { var msg = new SipMessage(examples('siprec')); msg.payload.length.should.eql(2);