UNPKG

happy-client

Version:

A JavaScript client to interact with Happy backend.

28 lines (24 loc) 636 B
'use strict'; /** * This function will take url parts as an array and normalize the path. Use this instead of * stupid string concatenating.. * @param args array of path arguments * @returns {string} */ function normalizeUrl(...args) { args = args .filter(arg => arg !== '/') .map(arg => { if (arg.startsWith("/")) { arg = arg.substring(1); } if (arg.endsWith("/")) { arg = arg.substring(0, arg.length - 1); } return arg; }); return args.join("/"); } module.exports = { normalizeUrl: normalizeUrl };