drachtio-srf 4.5.29 → 4.5.31

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.
@@ -224,7 +224,10 @@ function parseUri(s) {
224
224
  // eslint-disable-next-line max-len
225
225
  //const re = /^(sips?):(?:([^\s>:@]+)(?::([^\s@>]+))?@)?([\w\-\.]+)(?::(\d+))?((?:;[^\s=\?>;]+(?:=[^\s?\;]+)?)*)(?:\?(([^\s&=>]+=[^\s&=>]+)(&[^\s&=>]+=[^\s&=>]+)*))?$/;
226
226
  // eslint-disable-next-line max-len
227
- 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&=>]+)*))?$/;
227
+ 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&=>]+)*))?$/;
228
+ // eslint-disable-next-line max-len
229
+ //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&=>]+)*))?$/;
230
+
228
231
 
229
232
  const r = re.exec(s);
230
233
 
package/lib/srf.js CHANGED
@@ -28,9 +28,9 @@ DialogDirection.Recipient = 'recipient';
28
28
  const sleepFor = async(ms) => await new Promise((resolve) => setTimeout(resolve, ms));
29
29
 
30
30
  const noncopyableHdrs = ['via', 'from', 'to', 'call-id', 'cseq', 'contact', 'content-length', 'content-type'];
31
- function copyAllHeaders(msg, obj) {
32
- if (msg) Object.keys(msg.headers).forEach((h) => {
33
- if (!noncopyableHdrs.includes(h) && !obj[h]) obj[h] = msg.headers[h];});
31
+ function copyAllHeaders(headers, obj) {
32
+ if (headers) Object.keys(headers).forEach((h) => {
33
+ if (!noncopyableHdrs.includes(h) && !obj[h]) obj[h] = headers[h];});
34
34
  }
35
35
  function possiblyRemoveHeaders(hdrList, obj) {
36
36
  hdrList.forEach((h) => {
@@ -811,8 +811,9 @@ class Srf extends Emitter {
811
811
 
812
812
  // pass specified headers on to the B leg
813
813
  if (proxyRequestHeaders[0] === 'all') {
814
- copyAllHeaders(req, opts.headers);
815
- possiblyRemoveHeaders(proxyRequestHeaders.slice(1), opts.headers);
814
+ const reqHeaders = req.headers;
815
+ possiblyRemoveHeaders(proxyRequestHeaders.slice(1), reqHeaders);
816
+ copyAllHeaders(reqHeaders, opts.headers);
816
817
  }
817
818
  else proxyRequestHeaders.forEach((hdr) => { if (req.has(hdr)) opts.headers[hdr] = req.get(hdr);}) ;
818
819
 
@@ -904,8 +905,9 @@ class Srf extends Emitter {
904
905
  }
905
906
 
906
907
  if (proxyResponseHeaders[0] === 'all') {
907
- copyAllHeaders(uacRes, headers);
908
- possiblyRemoveHeaders(proxyResponseHeaders.slice(1), headers);
908
+ const resHeaders = uacRes.headers;
909
+ possiblyRemoveHeaders(proxyRequestHeaders.slice(1), resHeaders);
910
+ copyAllHeaders(resHeaders, headers);
909
911
  }
910
912
  else {
911
913
  proxyResponseHeaders.forEach((hdr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drachtio-srf",
3
- "version": "4.5.29",
3
+ "version": "4.5.31",
4
4
  "description": "drachtio signaling resource framework",
5
5
  "main": "lib/srf.js",
6
6
  "types": "lib/@types/index.d.ts",
@@ -127,6 +127,13 @@ describe('Parser', function () {
127
127
  uri.user.should.eql('116751x0');
128
128
  uri.scheme.should.eql('sips');
129
129
  });
130
+ it('should parse a sip uri with host part being simple label', function () {
131
+ var uri = parseUri('sip:116751@feature-server');
132
+ uri.family.should.eql('ipv4');
133
+ uri.host.should.eql('feature-server');
134
+ uri.user.should.eql('116751');
135
+ uri.scheme.should.eql('sip');
136
+ });
130
137
  it('should parse a multi-part header', function () {
131
138
  var msg = new SipMessage(examples('siprec'));
132
139
  msg.payload.length.should.eql(2);