Skip to content

Commit 8692100

Browse files
committed
fix: support single http-get urls, close #209
1 parent 6423340 commit 8692100

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

.travis.yml

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ script:
1515
- npm run demo5
1616
- npm run demo6
1717
- npm run demo7
18+
# hmm why are some demos skipped?
19+
- npm run demo11
1820
- START_SERVER_AND_TEST_INSECURE=1 npm run demo9
1921
- npm run demo-cross-env
2022
- npm run demo-commands

src/utils-spec.js

+16
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ describe('utils', () => {
8383
la(isUrlOrPort('http://foo.com'))
8484
la(isUrlOrPort('http://foo.com/bar/baz.html'))
8585
la(isUrlOrPort('http://localhost:6000'))
86+
la(isUrlOrPort('https://google.com'))
87+
})
88+
89+
it('allows url with http-get', () => {
90+
la(isUrlOrPort('http-get://localhost'))
91+
la(isUrlOrPort('http-get://foo.com'))
92+
la(isUrlOrPort('http-get://foo.com/bar/baz.html'))
93+
la(isUrlOrPort('http-get://localhost:6000'))
94+
})
95+
96+
it('allows url with https-head', () => {
97+
la(isUrlOrPort('https-head://localhost:6000'))
98+
})
99+
100+
it('allows url with https-options', () => {
101+
la(isUrlOrPort('https-head://foo'))
86102
})
87103

88104
it('allows port number or string', () => {

src/utils.js

+8
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,21 @@ const isPackageScriptName = command => {
7373
return Boolean(packageJson.scripts[command])
7474
}
7575

76+
const isWaitOnUrl = s => /^https?-(?:get|head|options)/.test(s)
77+
7678
const isUrlOrPort = input => {
7779
const str = is.string(input) ? input.split('|') : [input]
7880

7981
return str.every(s => {
8082
if (is.url(s)) {
8183
return s
8284
}
85+
// wait-on allows specifying HTTP verb to use instead of default HEAD
86+
// and the format then is like "http-get://domain.com" to use GET
87+
if (isWaitOnUrl(s)) {
88+
return s
89+
}
90+
8391
if (is.number(s)) {
8492
return is.port(s)
8593
}

0 commit comments

Comments
 (0)