File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1
1
# is-url-http
2
2
3
-
4
3
![ Last version] ( https://img.shields.io/github/tag/Kikobeats/is-url-http.svg?style=flat-square )
5
4
[ ![ Build Status] ( https://img.shields.io/travis/Kikobeats/is-url-http/master.svg?style=flat-square )] ( https://travis-ci.org/Kikobeats/is-url-http )
6
5
[ ![ Coverage Status] ( https://img.shields.io/coveralls/Kikobeats/is-url-http.svg?style=flat-square )] ( https://coveralls.io/github/Kikobeats/is-url-http )
@@ -28,6 +27,17 @@ isUrlHttp('mailto://kiko@beats.com') // ==> false
28
27
isUrlHttp (' callto:192.168.103.77+type=ip' ) // ==> false
29
28
```
30
29
30
+ If you need to run the package in a browser environment, you can save some bytes using the lightweight version:
31
+
32
+ ``` js
33
+ const isUrlHttp = require (' is-url-http/lightweight' )
34
+
35
+ isUrlHttp (' https://kikobeats.com' ) // ==> true
36
+ isUrlHttp (' https://kikobeats.com' ) // ==> true
37
+ isUrlHttp (' mailto://kiko@beats.com' ) // ==> false
38
+ isUrlHttp (' callto:192.168.103.77+type=ip' ) // ==> false
39
+ ```
40
+
31
41
## License
32
42
33
43
** is-url-http** © [ Kiko Beats] ( https://kikobeats.com ) , released under the [ MIT] ( https://github.com/Kikobeats/is-url-http/blob/master/LICENSE.md ) License.<br >
Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const URL = global . window ? window . URL : require ( 'url' ) . URL
4
+ const REGEX_HTTP_PROTOCOL = / ^ h t t p s ? : \/ \/ / i
5
+
6
+ module . exports = url => {
7
+ try {
8
+ return REGEX_HTTP_PROTOCOL . test ( new URL ( url ) . href )
9
+ } catch ( err ) {
10
+ return false
11
+ }
12
+ }
Original file line number Diff line number Diff line change 3
3
"description" : " Check if an URL is a valid HTTP URL." ,
4
4
"homepage" : " https://nicedoc.io/Kikobeats/is-url-http" ,
5
5
"version" : " 2.0.1" ,
6
+ "browser" : " lightweight.js" ,
6
7
"main" : " index.js" ,
7
8
"author" : {
8
9
"email" : " josefrancisco.verdu@gmail.com" ,
51
52
"node" : " >= 8"
52
53
},
53
54
"files" : [
54
- " index.js"
55
+ " index.js" ,
56
+ " lightweight.js"
55
57
],
56
58
"scripts" : {
57
59
"clean" : " rm -rf node_modules" ,
77
79
"*.md" : [
78
80
" standard-markdown"
79
81
]
80
- }
82
+ },
83
+ "umd:main" : " lightweight.js" ,
84
+ "unpkg" : " lightweight.js"
81
85
}
You can’t perform that action at this time.
0 commit comments