-
-
Notifications
You must be signed in to change notification settings - Fork 935
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize the URL in the baseUrl
option
#579
Changes from 2 commits
7c4478a
294ee69
f2278b6
1af5cde
f074094
fbf4174
2e17859
ca78716
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ test.before('setup', async () => { | |
response.end(request.url); | ||
}); | ||
|
||
s.on('/test/foobar', (request, response) => { | ||
response.end(request.url); | ||
}); | ||
|
||
s.on('/?test=it’s+ok', (request, response) => { | ||
response.end(request.url); | ||
}); | ||
|
@@ -194,6 +198,18 @@ test('allows extra keys in `hooks`', async t => { | |
await t.notThrowsAsync(() => got(`${s.url}/test`, {hooks: {extra: {}}})); | ||
}); | ||
|
||
test('baseUrl works', async t => { | ||
const instanceA = got.extend({baseUrl: `${s.url}/test`}); | ||
const {body} = await instanceA('/foobar'); | ||
t.is(body, `/test/foobar`); | ||
}); | ||
|
||
test('backslash is optional (baseUrl)', async t => { | ||
const instanceA = got.extend({baseUrl: `${s.url}/test/`}); | ||
const {body} = await instanceA('/foobar'); | ||
t.is(body, `/test/foobar`); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also add a test with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And a couple of tests where the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup |
||
|
||
test('throws when trying to modify baseUrl after options got normalized', async t => { | ||
const instanceA = got.create({ | ||
methods: [], | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prenormalize
is not a word, so should bepreNormalize
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure