commonfields:
  id: UnEscapeIPs
  version: -1
name: UnEscapeIPs
script: |-
  function format_ip(ip) {
      return ip.replace(/\[\.\]/g,'.');
  }

  function format_ip_list(ip_list) {
      var len = ip_list.length;
      var formatted_ips = new Array(len);
      ip_list.forEach(function(the_ip, index) {
          formatted_ips[index] = format_ip(the_ip.trim());
      });
      return formatted_ips;
  }

  var ips;
  if (Array.isArray(args.input)) {
      ips = format_ip_list(args.input);
  } else {
      // Assumed alternative is that args.input is a string
      var unformatted_ips = argToList(args.input);
      ips = format_ip_list(unformatted_ips);
      if (ips.length === 1) {
          return ips[0];
      }
  }
  return ips
type: javascript
tags:
- indicator-format
comment: |-
  Remove escaping chars from IP
  127[.]0[.]0[.]1 -> 127.0.0.1
enabled: true
args:
- name: input
  description: ip(s) to unescape
  isArray: true
scripttarget: 0
runonce: false
runas: DBotWeakRole
releaseNotes: Update script to accept array input
tests:
  - UnEscapeIPs-Test 

commonfields:
  id: UnEscapeIPs
  version: -1
name: UnEscapeIPs
script: |-
  function format_ip(ip) {
      return ip.replace(/\[\.\]/g,'.');
  }

  function format_ip_list(ip_list) {
      var len = ip_list.length;
      var formatted_ips = new Array(len);
      ip_list.forEach(function(the_ip, index) {
          formatted_ips[index] = format_ip(the_ip.trim());
      });
      return formatted_ips;
  }

  var ips;
  // It is assumed that args.input is a string
  var unformatted_ips = argToList(args.input);
  ips = format_ip_list(unformatted_ips);
  return ips;
type: javascript
tags:
- indicator-format
comment: |-
  Remove escaping chars from IP
  127[.]0[.]0[.]1 -> 127.0.0.1
enabled: true
args:
- name: input
  description: ip(s) to unescape
  isArray: true
scripttarget: 0
runonce: false
runas: DBotWeakRole
releaseNotes: Update script to accept array input
tests:
  - UnEscapeIPs-Test 

Remove unnecessary conditional statement from UnEscapeIPs script
Remove unnecessary conditional statement from UnEscapeIPs script
