Skip to content

Commit 30da7a7

Browse files
committed
Fix bad introspection result for an endpoint URL string
1 parent 8341829 commit 30da7a7

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { parseEndpoint } from '../helpers/utils.js';
2+
3+
describe('parseEndpoint', () => {
4+
it('should parse an endpoint URL and provide default headers', () => {
5+
const endpoint = parseEndpoint('https://api.github.com');
6+
expect(endpoint).toEqual({
7+
url: 'https://api.github.com',
8+
method: 'POST',
9+
headers: {
10+
'Content-Type': 'application/json',
11+
},
12+
});
13+
});
14+
15+
it('should parse an endpoint object and provide default headers', () => {
16+
const endpoint = parseEndpoint({ url: 'https://api.github.com', method: 'GET' });
17+
expect(endpoint).toEqual({
18+
url: 'https://api.github.com',
19+
method: 'GET',
20+
});
21+
});
22+
});

packages/action/helpers/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ export function parseEndpoint(endpoint: Endpoint): {
112112
return {
113113
url: endpoint,
114114
method: 'POST',
115+
headers: {
116+
'Content-Type': 'application/json',
117+
}
115118
};
116119
}
117120

0 commit comments

Comments
 (0)