-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update URL validation to handle GitHub URLs properly
Co-Authored-By: Michael Latman <[email protected]>
- Loading branch information
1 parent
7fa56ee
commit 3872b8f
Showing
2 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { validateRequiredFields } from './pr-check.js'; | ||
|
||
describe('validateRequiredFields', () => { | ||
test('accepts valid GitHub URLs', () => { | ||
const pkg = { | ||
name: 'test-package', | ||
description: 'Test package', | ||
vendor: 'Test Vendor', | ||
sourceUrl: 'https://github.com/owner/repo', | ||
homepage: 'https://github.com/owner/repo', | ||
license: 'MIT', | ||
runtime: 'node' | ||
}; | ||
expect(() => validateRequiredFields(pkg)).not.toThrow(); | ||
}); | ||
|
||
test('rejects invalid URLs without protocol', () => { | ||
const pkg = { | ||
name: 'test-package', | ||
description: 'Test package', | ||
vendor: 'Test Vendor', | ||
sourceUrl: 'github.com/owner/repo', | ||
homepage: 'https://github.com/owner/repo', | ||
license: 'MIT', | ||
runtime: 'node' | ||
}; | ||
expect(() => validateRequiredFields(pkg)).toThrow(/invalid sourceUrl URL/); | ||
}); | ||
|
||
test('accepts both http and https protocols', () => { | ||
const pkg = { | ||
name: 'test-package', | ||
description: 'Test package', | ||
vendor: 'Test Vendor', | ||
sourceUrl: 'http://github.com/owner/repo', | ||
homepage: 'https://github.com/owner/repo', | ||
license: 'MIT', | ||
runtime: 'node' | ||
}; | ||
expect(() => validateRequiredFields(pkg)).not.toThrow(); | ||
}); | ||
}); |