Skip to content

Commit 548b2af

Browse files
committed
Fix fallback to latest version in tools.ts
1 parent 14ee952 commit 548b2af

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

__tests__/tools.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,19 @@ describe('Tools tests', () => {
244244
}
245245
);
246246

247+
it('checking getUrl handles undefined version without double slash', async () => {
248+
const data = getData({
249+
tool: 'cs2pr',
250+
repository: 'staabm/annotate-pull-request-from-checkstyle',
251+
domain: 'https://github.com'
252+
});
253+
data['extension'] = '';
254+
delete data['version'];
255+
expect(await tools.getUrl(data)).toBe(
256+
'https://github.com/staabm/annotate-pull-request-from-checkstyle/releases/download/cs2pr'
257+
);
258+
});
259+
247260
it.each`
248261
version | version_prefix | url
249262
${'latest'} | ${''} | ${'https://example.com/tool.phar'}

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export async function filterList(tools_list: string[]): Promise<string[]> {
156156
* @param data
157157
*/
158158
export async function getUrl(data: RS): Promise<string> {
159-
if (data['version'] === 'latest') {
159+
if ((data['version'] ?? 'latest') === 'latest') {
160160
return [
161161
data['domain'],
162162
data['repository'],

0 commit comments

Comments
 (0)