dappnode / DNP_ADMIN

DAppNode tool responsible for providing the admin UI of DAppNode
http://admin.dappnode
GNU General Public License v3.0
7 stars 21 forks source link

Minimize the chance of a string prototype error #343

Closed dapplion closed 5 years ago

dapplion commented 5 years ago

Change

name.split("-")

with

stringSplit(name, "-")

// utils/strings

export const stringSplit = (s, separator) => {
  if (!s || typeof s !== "string") return [""];
  if (!separator) return [""];
  return s.split(separator);
};

which checks the variable existance and its type before calling a prototype method