only trim trailing / on filepaths
Trailing / in urlpath may be important to routing, so we shouldn't strip it.
If there is an error with the URL, it is not the responsibility of Binder to fix it.
@@ -95,10 +95,11 @@ Image.prototype.launch = function(url, token, path, pathType) {
if (path) {
// strip trailing /
url = url.replace(/\/$/, '');
- // trim trailing and leading '/'
- // trailing '/' causes ERR_TOO_MANY_REDIRECTS in user server
- path = path.replace(/(^\/)|(\/?$)/g, '');
+ // trim leading '/'
+ path = path.replace(/(^\/)/g, '');
if (pathType === 'file') {
+ // trim trailing / on file paths
+ path = path.replace(/(\/$)/g, '');
// /tree is safe because it allows redirect to files
// need more logic here if we support things other than notebooks
url = url + '/tree/' + encodeURI(path);
