drachtio-srf 4.5.13 → 4.5.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/sip-parser/message.js +6 -1
- package/lib/srf.js +1 -1
- package/package.json +1 -1
- package/test/unit-tests/parser.js +10 -0
|
@@ -86,7 +86,12 @@ class SipMessage {
|
|
|
86
86
|
|
|
87
87
|
getParsedHeader(hdr) {
|
|
88
88
|
const name = parser.getHeaderName(hdr) ;
|
|
89
|
-
const v = this.headers[name]
|
|
89
|
+
const v = this.headers[name];
|
|
90
|
+
|
|
91
|
+
if (!v) {
|
|
92
|
+
throw new Error('header not available');
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
const fn = parser.getParser(hdr.toLowerCase()) ;
|
|
91
96
|
return fn({s:v, i:0}) ;
|
|
92
97
|
}
|
package/lib/srf.js
CHANGED
|
@@ -821,7 +821,7 @@ class Srf extends Emitter {
|
|
|
821
821
|
if (!(opts.headers.to || opts.headers.To) && !opts.calledNumber) { opts.calledNumber = req.calledNumber; }
|
|
822
822
|
|
|
823
823
|
opts.localSdp = opts.localSdpB && typeof opts.localSdpB !== 'function' ? opts.localSdpB : req.body ;
|
|
824
|
-
const is3pcc = !opts.localSdp;
|
|
824
|
+
const is3pcc = !opts.localSdp || opts.noAck;
|
|
825
825
|
if (is3pcc) opts.noAck = true;
|
|
826
826
|
|
|
827
827
|
let remoteSdpB, translatedRemoteSdpB ;
|
package/package.json
CHANGED
|
@@ -40,6 +40,10 @@ describe('Parser', function () {
|
|
|
40
40
|
msg.set('From', '<sip:daveh@localhost>;tag=1234');
|
|
41
41
|
msg.get('from').should.eql('<sip:daveh@localhost>;tag=1234');
|
|
42
42
|
});
|
|
43
|
+
it('should not parse a header when not available', function () {
|
|
44
|
+
var msg = new SipMessage();
|
|
45
|
+
should.throws(msg.getParsedHeader.bind(msg, 'contact'));
|
|
46
|
+
});
|
|
43
47
|
it('should parse multiple headers into an array', function () {
|
|
44
48
|
var msg = new SipMessage(examples('invite'));
|
|
45
49
|
var via = msg.getParsedHeader('via');
|
|
@@ -146,5 +150,11 @@ describe('Parser', function () {
|
|
|
146
150
|
msg.get('From').should.eql('"Dave" <sip:daveh@localhost>;tag=1234');
|
|
147
151
|
msg.callingName.should.eql('Dave');
|
|
148
152
|
});
|
|
153
|
+
it('should parse calling name', function () {
|
|
154
|
+
var msg = new SipMessage();
|
|
155
|
+
msg.set('From', '"Dave" <sip:daveh@localhost>;tag=1234');
|
|
156
|
+
msg.get('From').should.eql('"Dave" <sip:daveh@localhost>;tag=1234');
|
|
157
|
+
msg.callingName.should.eql('Dave');
|
|
158
|
+
});
|
|
149
159
|
});
|
|
150
160
|
|