-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against bad default frontends (#61)
* Guard against bad default frontends * review update
- Loading branch information
Showing
2 changed files
with
36 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { describe, it, expect } from 'vitest'; | ||
import { isValidUrl } from './is-valid-url'; | ||
|
||
describe('isValidUrl', () => { | ||
it('should return true for valid http URLs', () => { | ||
expect(isValidUrl('http://example.com')).toBe(true); | ||
expect(isValidUrl('http://www.example.com')).toBe(true); | ||
expect(isValidUrl('http://example.com/path')).toBe(true); | ||
expect(isValidUrl('http://example.com?q=query')).toBe(true); | ||
}); | ||
|
||
it('should return true for valid https URLs', () => { | ||
expect(isValidUrl('https://example.com')).toBe(true); | ||
expect(isValidUrl('https://www.example.com')).toBe(true); | ||
expect(isValidUrl('https://example.com/path')).toBe(true); | ||
expect(isValidUrl('https://example.com?q=query')).toBe(true); | ||
}); | ||
|
||
it('should return false for URLs with unsupported protocols', () => { | ||
expect(isValidUrl('ftp://example.com')).toBe(false); | ||
expect(isValidUrl('mailto:[email protected]')).toBe(false); | ||
expect(isValidUrl('chrome-extension://lkpmkhpnhknhmibgnmmhdhgdilepfghe/page.html')).toBe(false); | ||
}); | ||
|
||
it('should return false for strings that are not URLs', () => { | ||
expect(isValidUrl('justastring')).toBe(false); | ||
expect(isValidUrl('www.example.com')).toBe(false); | ||
expect(isValidUrl('12345')).toBe(false); | ||
expect(isValidUrl('')).toBe(false); | ||
}); | ||
}); |
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