Files
coucou/NotchBuddy/Sources/App/SafeWebURL.swift
c73c79d048 feat(security): extract safeWebURL, add tests, update docs and CI
- 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>
2026-10-01 10:33:46 +02:00

13 lines
584 B
Swift

import Foundation
/// Returns the URL only if it is a plain web link (http/https with a host). Model output
/// and API data can carry file://, smb:// or custom app schemes that would launch local apps
/// or deep links; those never reach NSWorkspace.open.
func safeWebURL(_ string: String?) -> URL? {
guard let string,
let url = URL(string: string.trimmingCharacters(in: .whitespacesAndNewlines)),
let scheme = url.scheme?.lowercased(), scheme == "https" || scheme == "http",
let host = url.host, !host.isEmpty else { return nil }
return url
}