Set strict routing that /buckets/test/abc is not the same as /buckets/test/abc/ adding the slash at the end denotes creating a folder and not a file
190287
function (req, res) {
                var s3 = new AWS.S3(),
                    bucket = req.params.name,
                    location = getLocation(req),
                    params = {
                        Bucket: bucket,
                        Delimiter: req.query.delimiter,
                        Marker: req.query.marker,
                        MaxKeys: req.query.maxKeys || DEFAULT_MAX_KEYS,
                        Prefix: req.query.prefix
                    },
                    handleListObjects = function (err, data) {
                        if (err) {
                            res.status(500).send(err);
                        } else {
                              
                            // Get link for this set
                            data.links = [{
                                rel: 'self',
                                href: getOriginalink(req)
                            }];
                            
                            // Map through bucket contents to filter out self reference and add links
                            data.Contents = data.Contents.map(function (content) {
                                // Add s3g link to reference the resource
                                content.links = [{
                                    ref: 'self',
                                    href: getS3ObjectLink(req, bucket, content)
                                }];
                                
                                // Filter out any references to the parent file
                                if (location.origin + location.search !== content.links[0].href) {
                                    return content;
                                }
                                
                            }).filter(Boolean);
                            
                            
                            // If this set of objects has a next marker that means there are > 1000 so provide the link to the next set of data
                            if (data.IsTruncated) {
                                // Get link for next set using next marker if available or the last key in the content set
                                data.links.push({
                                    rel: 'next',
                                    href: getNextMarkerLink(req, data.NextMarker || data.Contents[data.Contents.length - 1].Key)
                                });
                            }
                            res.json(data);
                        }
                    };
                
                s3.listObjects(params, handleListObjects);
            }
1353385
function (root_path, default_prefix) {
		var arr = SR.Settings.SR_PATH.split(SR.path.sep);
		var prefix = arr[arr.length-1] + '-';
		var dirs = UTIL.getDirectoriesSync(root_path);

		if (default_prefix)
			prefix = default_prefix;
		
		//LOG.warn('default_prefix: ' + default_prefix + ' prefix: ' + prefix + ' paths to check:');
		for (var i in dirs) {
			//LOG.warn(dirs[i]);
			if (dirs[i].startsWith(prefix)) { 
				SR.Settings.MOD_PATHS.push(SR.path.resolve(root_path, dirs[i]));
			}
		}
	}
569615
function(parts) {
        var urls = [];
        var start = '';

        // If the first part is empty
        // the original path begins with a slash so we
        // do that, too

        if( _.isEmpty(parts[0]) ) {
            start = '/';
            urls[0] = '/';      // would not be generated in reduce()
        }

        _.reduce(parts, function(acc, value){

            if( ! _.isString(value) || _.isEmpty(value) )
                return acc;

            acc += value;

            // Push w/out trailing slash
            urls.push(acc);

            return acc + '/';
        }, start );

        return urls;
    }
1298731
def put_and_get_url(path, options = {})
      ext = options[:ext] || File.extname(path)
      path = path.to_s
      tname = put(path, :ext => ext)

      "http://img0#{rand(4)+1}.taobaocdn.com/tfscom/#{t}#{ext}" unless tname.nil?
    end
737384
function _buildRoute(route) {

  let newRoute = route;

  // Normalize the route string
  newRoute = (newRoute.indexOf('/') === 0) ? newRoute.slice(1, newRoute.length) : newRoute;
  newRoute = '/' + newRoute;

  // Prepend the root if the user defined one
  newRoute = (Nasa.__config__['root']) ? Nasa.__config__['root'] + newRoute : newRoute;

  return newRoute;
}
44022
def isdir(self, path):
        
        (bucket, key) = self._path_to_bucket_and_key(path)

        s3_bucket = self.s3.Bucket(bucket)

        # root is a directory
        if self._is_root(key):
            return True

        for suffix in (S3_DIRECTORY_MARKER_SUFFIX_0,
                       S3_DIRECTORY_MARKER_SUFFIX_1):
            try:
                self.s3.meta.client.get_object(
                    Bucket=bucket, Key=key + suffix)
            except botocore.exceptions.ClientError as e:
                if not e.response['Error']['Code'] in ['NoSuchKey', '404']:
                    raise
            else:
                return True

        # files with this prefix
        key_path = self._add_path_delimiter(key)
        s3_bucket_list_result = list(itertools.islice(
            s3_bucket.objects.filter(Prefix=key_path), 1))
        if s3_bucket_list_result:
            return True

        return False
1093111
boolean seemsLikeADirectoryAndUsePseudoDirectories(Storage storage) {
    if (!fileSystem.config().usePseudoDirectories()) {
      return false;
    }
    if (path.seemsLikeADirectory()) {
      return true;
    }
    // fancy case: the file name doesn't end in slash, but we've been asked to have pseudo dirs.
    // Let's see if there are any files with this prefix.
    if (storage == null) {
      // we are in a context where we don't want to access the storage, so we conservatively
      // say this isn't a directory.
      return false;
    }
    // Using the provided path + "/" as a prefix, can we find one file? If so, the path
    // is a directory.
    String prefix = path.removeBeginningSeparator().toString();
    if (!prefix.endsWith("/")) {
      prefix += "/";
    }
    Page<Blob> list =
        storage.list(
            this.bucket(),
            Storage.BlobListOption.prefix(prefix),
            // we only look at the first result, so no need for a bigger page.
            Storage.BlobListOption.pageSize(1),
            fileSystem.provider().getProject() == null
                ? null
                : Storage.BlobListOption.userProject(fileSystem.provider().getProject()));
    for (Blob b : list.getValues()) {
      // if this blob starts with our prefix and then a slash, then prefix is indeed a folder!
      if (b.getBlobId() == null) {
        continue;
      }
      String name = b.getBlobId().getName();
      if (name == null) {
        continue;
      }
      if (("/" + name).startsWith(this.path.toAbsolutePath() + "/")) {
        return true;
      }
    }
    // no match, so it's not a directory
    return false;
  }
868981
public void setExtendsDirectory(String extendsDirectory) {
        this.extendsDirectory = UrlUtils.cleanDirectory(extendsDirectory);
        if ("/".equals(this.extendsDirectory)) {
            this.extendsDirectory = null;
        }
        fileMethod.setExtendsDirectory(extendsDirectory);
    }
458337
function strictPathing(req, res, next){
	var reqres = ackNode.reqres(req, res)
		,abUrl = reqres.req.absoluteUrl()//pre-load form and multi-part posts
		,oUrl = abUrl

	abUrl = abUrl.replace(/([^:]\/)\/+/g, "$1")//replace double slashes with single (ignore :// and opening slashes)
	if(abUrl != oUrl){
		return reqres.relocate(abUrl, 'tidy-url')
	}

	next()
}
606107
def url2fs(url):
    
    uri, extension = posixpath.splitext(url)
    return safe64.dir(uri) + extension
581718
function requireValidArgsRoute (args) {
    // do not check if strict mode not set
    if (!this.strict) {
        return
    }
    // require valid session
    this.requireValidSession(args.session)
    // require route and method
    assert.ok(typeof args.path === 'string' && typeof args.method === 'string', 'route and method required to request access for route')
    // path must start with /
    assert.ok(args.path.charAt(0) === '/', 'path must start with slash')
}
1248101
function getBucket(path, name, parent){

		// Does it already exist?
		var id = prefix + path.replace(/\W/g,''),
			tab = doc.getElementById(id),
			label = doc.getElementById("label"+id);

		// Network
		var network = path.replace(/\:.*/, '');

		// Set current path
		if(!label&&name){
			label = doc.createElement('a');
			label.innerHTML = name;
			label.id = "label"+id;
			if(parent){
				label.setAttribute('data-parent', parent);
			}
			label.onclick = function(){
				getBucket(path, name, parent);
			};
			path_el.appendChild(label);
		}


		if(!tab){

			// create a new tab
			tab = doc.createElement('ul');
			tab.id = id;
			tab.innerHTML = "<span class='"+prefix+"loading' data-message='Waiting for signin'><span></span></span>";
			body_el.appendChild(tab);

			// Remove loading
			var span = tab.getElementsByTagName('span')[0];

			// Login
			hello.login(network, function(auth){

				if(!auth||auth.error){
					span.setAttribute('data-message', "Signin failed, try again");
					span.setAttribute('data-animate', false);
					span.onclick = function(){
						tab.parentNode.removeChild(tab);
						getBucket(path, name, parent);
					};
					return;
				}

				span.setAttribute('data-message', "Loading files");

				// API
				hello.api(path, function(r){
					span.parentNode.removeChild(span);

					// Add files to the tab
					for(var i=0;i<r.data.length;i++){
						ref.push( new fileRef(r.data[i], network, tab) );
					}
				});
			});

		}


		// Hide the others
		// LISTS
		var a = body_el.children;
		for(var i=0;i<a.length;i++){
			a[i].style.display = "none";
		}

		// LABELS
		a = path_el.getElementsByTagName('a');
		for(i=a.length-1;i>=0;--i){
			if(parent&&a[i].id === "label"+parent){
				//parent = a[i].getAttribute('data-parent');
				a[i].style.display = "inline-block";
			}
			else if(a[i].id === "label"+id){
				a[i].style.display = "inline-block";
			}
			else{
				a[i].style.display = "none";
			}
		}


		// Update global
		current_folder = path;

		current_bucket = tab;

		current_network = network;

		// show this
		tab.style.display = 'block';

		// Update the upload btn
		upload_btn.innerHTML = name?"Upload to " + name.replace(/^[a-z]/,function(r){return r.toUpperCase();}):'Upload';
	}
491090
function (path) {
		var mockDirConfig = {
			openRoute: function (req, res, params) {
			},
			
			closeRoute: function (req, res, params) {
			},
		};

		spyOn(mockDirConfig, 'openRoute').and.callThrough();
		spyOn(mockDirConfig, 'closeRoute').and.callThrough();

		registerRequireMock(testObject._formatPathForRequire(path), function () {
			return mockDirConfig;
		});

		filesThatExist.push(path);

		return mockDirConfig;
	}
535791
def add_route(route, endpoint=None, **kw):
    

    # ensure correct amout of slashes
    def apiurl(route):
        return '/'.join(s.strip('/') for s in ["", BASE_URL, route])

    return add_senaite_route(apiurl(route), endpoint, **kw)
497463
def split_s3_path(url: str) -> Tuple[str, str]:
    """"""
    parsed = urlparse(url)
    if not parsed.netloc or not parsed.path:
        raise ValueError("bad s3 path {}".format(url))
    bucket_name = parsed.netloc
    s3_path = parsed.path
    # Remove '/' at beginning of path.
    if s3_path.startswith("/"):
        s3_path = s3_path[1:]
    return bucket_name, s3_path
584842
def bind_path(self, name, folder):
        """"""
        if not len(name) or name[0] != '/' or name[-1] != '/':
            raise ValueError(
                "name must start and end with '/': {0}".format(name))
        self._folder_masks.insert(0, (name, folder))
5195
function makeHref(to, params, query) {
        var path = Router.makePath(to, params, query);
        return location === HashLocation ? '#' + path : path;
      }