Skip to content

Jeffrey-Zutt/slash-sandwich

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slash sandwich

Glues parts together divided by a single slash.

Installation:

npm i slash-sandwich

Examples:

    import slashSandwich from "slash-sandwich"

    slashSandwich(["foo", "bar"])                                    // Result: "/foo/bar/"
    slashSandwich(["foo", "bar"], { trailingSlash: false })          // Result: "/foo/bar"
    slashSandwich(["foo", "bar"], { leadingSlash: false })           // Result: "foo/bar/"

    // `null` and `undefined` are stripped    
    slashSandwich(["foo", undefined "bar"])                         // Result: "/foo/bar/"

    // leadingSlash is automatically stripped 
    // when string starts with "http://" or "https://"
    slashSandwich(["http://www.domain.com/", "/bar"])               // Result: "http://www.domain.com/bar/"   

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •