mirror of
https://github.com/Louis-CFM/coucou.git
synced 2026-12-07 07:32:35 +09:00
- Move safeWebURL(_:) from IslandViewContent.swift to SafeWebURL.swift so it can be compiled and tested independently - Add tests/SafeWebURLTests.swift: 15 cases (5 accepted, 10 rejected) - Add scripts/test-safe-links.sh on the same model as test-screen-geometry.sh - Add "Test link filter" step to build.yml after "Test screen geometry" - CHANGELOG: add entry for http/https-only links (#16) - docs/INTEGRATIONS.md: document that Open button is disabled for non-web URLs - docs/support.html: typographic apostrophes in French no-notch FAQ answer Co-authored-by: Cris1670 <20190806+Cris1670@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
28 lines
1.1 KiB
Swift
28 lines
1.1 KiB
Swift
import Foundation
|
|
|
|
@main
|
|
enum SafeWebURLTests {
|
|
static func main() {
|
|
// Accepted: plain http/https URLs
|
|
precondition(safeWebURL("https://example.com") != nil)
|
|
precondition(safeWebURL("http://example.com/a?b=1") != nil)
|
|
precondition(safeWebURL("HTTPS://EXAMPLE.COM") != nil)
|
|
precondition(safeWebURL(" https://example.com \n") != nil)
|
|
precondition(safeWebURL("http://localhost:5678") != nil)
|
|
|
|
// Rejected: nil, empty, non-web schemes, malformed
|
|
precondition(safeWebURL(nil) == nil)
|
|
precondition(safeWebURL("") == nil)
|
|
precondition(safeWebURL("file:///etc/hosts") == nil)
|
|
precondition(safeWebURL("javascript:alert(1)") == nil)
|
|
precondition(safeWebURL("vscode://file/etc/hosts") == nil)
|
|
precondition(safeWebURL("smb://server/share") == nil)
|
|
precondition(safeWebURL("mailto:a@b.c") == nil)
|
|
precondition(safeWebURL("https://") == nil)
|
|
precondition(safeWebURL("https:example.com") == nil)
|
|
precondition(safeWebURL("//example.com") == nil)
|
|
|
|
print("Safe web links: 15 cases passed")
|
|
}
|
|
}
|