1.0.0 • Published 6 years ago
react-steersman-url v1.0.0
React Steersman URL
Tiny and Fast URL utils
Usage
URI
interface URI {
protocol // returns protocol
username // returns username if exists otherwise false
password // returns password if exists otherwise false
hostname // returns hostname
port // returns port if exists otherwise false
host // returns host
origin // returns origin
path // returns path
pathParts // returns path parts
query // returns query
queryParams // returns query as object
hash // returns hash
toString() // converts URI instance to string
toObject() // converts URI instance to Object
}
const uri = URI.parse('https://example.com');
console.log(uri.toObject());
Pattern
interface Pattern {
static fromString(url: string): Pattern
build(params: object): string
match(url: string): (object|null)
}
const compiled = Pattern.fromString('/user/:userId(\\d+)|int');
const userId = 4520;
const url = compiled.build({ userId });
console.log(url) // /user/4520
const params = compiled.match(url);
console.log(params) // { userId: 4520 }
License
License The MIT License Copyright (c) 2017-2018 Ivan Zakharchanka
1.0.0
6 years ago
0.4.0
6 years ago
0.3.0
6 years ago
0.2.0
6 years ago
0.1.28
6 years ago
0.1.27
6 years ago
0.1.26
6 years ago
0.1.25
6 years ago
0.1.24
6 years ago
0.1.23
6 years ago
0.1.22
6 years ago
0.1.21
6 years ago
0.1.20
6 years ago
0.1.19
6 years ago
0.1.18
6 years ago
0.1.17
6 years ago
0.1.16
6 years ago
0.1.15
6 years ago
0.1.14
6 years ago
0.1.13
6 years ago
0.1.12
6 years ago
0.1.11
6 years ago
0.1.8
6 years ago
0.1.7
6 years ago
0.1.6
6 years ago