the regex should be wrapped in parens to avoid / ambiguity: `(/\/$/).test(...)`... but actually, I think this is over-use of regex (which junior codes need no extra reason to over-use ;-) ).

I'd rwrite this:
```javascript
return (path.length && path[path.length-1] === '/') ? '' : '/';
```

Actually I'd take it further and refactor both it and its callers:
```javascript
function standardizePath(path) { // rename to taste
  if (path.length && path[path.length-1] !== '/') path += '/';
  return path;
}
```

NOTE: the latter replacement has subtly different edge behavior for the empty string; salt to taste.