Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 811 Bytes

README.md

File metadata and controls

25 lines (18 loc) · 811 Bytes

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/"