mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(core): duplicated path if the error is thrown from parameter (#13967)
* fix(core): double namespace if the error is thrown from parameter * test: fix test case
This commit is contained in:
@@ -59,13 +59,13 @@ describe('v2 route throws an error', () => {
|
||||
expect(value).toBe('7');
|
||||
break;
|
||||
case 'Hot Routes:':
|
||||
expect(value).toBe('4 /test/:id<br>1 /test/slow<br>1 /thisDoesNotExist<br>');
|
||||
expect(value).toBe('4 /test/:id<br>');
|
||||
break;
|
||||
case 'Hot Paths:':
|
||||
expect(value).toBe('2 /test/error<br>2 /test/slow<br>1 /test/httperror<br>1 /thisDoesNotExist<br>1 /<br>');
|
||||
break;
|
||||
case 'Hot Error Routes:':
|
||||
expect(value).toBe('3 /test/:id<br>1 /test/slow<br>1 /thisDoesNotExist<br>');
|
||||
expect(value).toBe('3 /test/:id<br>');
|
||||
break;
|
||||
case 'Hot Error Paths:':
|
||||
expect(value).toBe('2 /test/error<br>1 /test/httperror<br>1 /test/slow<br>1 /thisDoesNotExist<br>');
|
||||
|
||||
@@ -33,15 +33,17 @@ describe('rand-user-agent', () => {
|
||||
});
|
||||
|
||||
it('should match ua configurated', async () => {
|
||||
const response1 = await got('https://httpbingo.org/user-agent');
|
||||
expect(response1.data['user-agent']).toBe(config.ua);
|
||||
nock('https://rsshub.test')
|
||||
.get('/test')
|
||||
.reply(function () {
|
||||
return [200, { ua: this.req.headers['user-agent'] }];
|
||||
});
|
||||
|
||||
const response2 = await got('https://httpbingo.org/user-agent', {
|
||||
const resonse = await got('https://rsshub.test/test', {
|
||||
headers: {
|
||||
'user-agent': mobileUa,
|
||||
},
|
||||
});
|
||||
expect(response2.data['user-agent']).toBe(mobileUa);
|
||||
expect(response2.data['user-agent']).not.toBe(config.ua);
|
||||
expect(resonse.data.ua).toBe(mobileUa);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user