jssip无法识别以数字开始的域

修改Grammar.js的parse_SIP_URI方法(大概在2886行)

      function parse_SIP_URI() {
        var result0, result1, result2, result3, result4, result5;
        var pos0, pos1;
        pos0 = pos;
        pos1 = pos;
        result0 = parse_uri_scheme();
        if (result0 !== null) {
          if (input.charCodeAt(pos) === 58) {
            result1 = ":";
            pos++;
          } else {
            result1 = null;
            if (reportFailures === 0) {
              matchFailed("\":\"");
            }
          }
          if (result1 !== null) {
            result2 = parse_userinfo();
            result2 = result2 !== null ? result2 : "";
            if (result2 !== null) {
              result3 = parse_hostport();
              if (result3 !== null) {
                result4 = parse_uri_parameters();
                if (result4 !== null) {
                  result5 = parse_headers();
                  result5 = result5 !== null ? result5 : "";
                  if (result5 !== null) {
                    result0 = [result0, result1, result2, result3, result4, result5];
                  } else {
                    result0 = null;
                    pos = pos1;
                  }
                } else {
                  result0 = null;
                  pos = pos1;
                }
              } else {
                result0 = null;
                pos = pos1;
              }
            } else {
              result0 = null;
              pos = pos1;
            }
          } else {
            result0 = null;
            pos = pos1;
          }
        } else {
          result0 = null;
          pos = pos1;
        }
        if (result0 !== null) {
          result0 = (function(offset) {
                            var header;
                            try {
                                data.uri = new URI(data.scheme, data.user, data.host, data.port, data.uri_params, data.uri_headers);
                                delete data.scheme;
                                delete data.user;
                                delete data.host;
                                delete data.host_type;
                                delete data.port;
                                delete data.uri_params;
                                if (startRule === 'SIP_URI') { data = data.uri;}
                              } catch(e) {
                                data = -1;
                              }})(pos0);
        }
        if (result0 === null) {
          pos = pos0;
        }
        // 以下代码为新加
        if(result0 === null){
          if(startRule === 'SIP_URI'){
            if(input.includes('@')){
              var t = input.split(/:|@/g);
              data = new URI(t[0], t[1], t[2]);
              result0 = undefined;
              pos = input.length;
            }
          }else if(startRule === 'From' || startRule === 'To'){
              var t = input.split(/<|>/g);
              data.tag = t[2].split('=')[1];
              t = t[1].split(/:|@/g);
              data.uri = new URI(t[0], t[1], t[2]);
              delete data.scheme;
              delete data.user;
              delete data.host;
              delete data.host_type;
              delete data.port;
              delete data.uri_params;
              result0 = undefined;
              pos = input.split('>')[0].length;
          } else if(startRule === 'Contact'){
            
          }
        }
        // 以上代码为新加
        return result0;
      }
上一篇:Java exception was raised during method invocation


下一篇:前台拼接table完成点击获取整行值(可以直接用)