prepend-protocol
v1.0.0
Published
Add protocols to URLs
Downloads
1
Maintainers
Readme
⚙️ Installation
npm i prepend-protocol
CDN Links:
- https://cdn.jsdelivr.net/npm/[email protected]/prepend-protocol.js
- https://www.unpkg.com/[email protected]/prepend-protocol.js
📖 Usage
◎ Import
// ES6
import prependProtocol from "prepend-protocol";
// commonjs
const prependProtocol = require("prepend-protocol");
◎ Prepend protocol
prependProtocol("www.example.com"); // "https://www.example.com"
prependProtocol("localhost") // "https://localhost"
// default protocol is always set to "https"
prependProtocol("ftp://www.example.com"); // "https://www.example.com"
prependProtocol("example.com", "ftp"); // "ftp://example.com"
prependProtocol("https://example.com", "ftp"); // "ftp://example.com"