const HostUtil = {
  stringToHostname: function (string) {
    const HOSTNAME_MAX_LENGTH = 63;

    // Strip or convert illegal characters
    let host = string.toLowerCase().replace(/[_\.]/g, '-').replace(/[^a-z0-9-]/g, '');

    // Strip symbols from beginning
    while (host.startsWith('-')) {
      host = host.slice(1);
    }

    // Strip symbols from middle if greater than max length
    while (host.length > HOSTNAME_MAX_LENGTH && host.charAt(HOSTNAME_MAX_LENGTH - 1) === '-') {
      host = host.slice(0, HOSTNAME_MAX_LENGTH - 1).concat(host.slice(HOSTNAME_MAX_LENGTH));
    }

    host = host.slice(0, HOSTNAME_MAX_LENGTH);

    // Strip symbols from end
    while (host.endsWith('-')) {
      host = host.slice(0, host.length - 1);
    }

    return host.slice(0, HOSTNAME_MAX_LENGTH);
  }
};

module.exports = HostUtil;

@@ -89,16 +89,70 @@
  = 63;%0A%0A
+    if (string == null) %7B%0A      return string;%0A    %7D%0A%0A
     // S

Add test for string being null in hostutil