Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1810681

Browse files
update
1 parent 6569591 commit 1810681

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

‎Sources/swiftui-loop-videoplayer/ext+/URL+.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ extension URL {
1414
/// Strategy:
1515
/// 1) Parse once to detect an existing scheme (mailto, ftp, etc.).
1616
/// 2) If a scheme exists and it's not http/https -> reject.
17-
/// 3) If no scheme exists -> optionally prepend https:// and parse again.
18-
static func validURLFromString(from raw: String, assumeHTTPSIfMissing: Bool = true) -> URL? {
17+
static func validURLFromString(from raw: String) -> URL? {
1918
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
2019

2120
// First parse to detect an existing scheme.
@@ -31,11 +30,6 @@ extension URL {
3130
return comps.url
3231
}
3332

34-
// No scheme present -> optionally add https://
35-
guard assumeHTTPSIfMissing else { return nil }
36-
guard let comps = URLComponents(string: "https://" + trimmed) else { return nil }
37-
guard let host = comps.host, !host.isEmpty else { return nil }
38-
if let port = comps.port, !(1...65535).contains(port) { return nil }
39-
return comps.url
33+
return nil
4034
}
4135
}

‎Tests/swiftui-loop-videoplayerTests/ext+/testURL.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ final class testURL: XCTestCase {
2929
}
3030
}
3131

32-
func testAddsHTTPSIfMissing() {
33-
// Given
34-
let raw = "example.com/path?x=1#y"
35-
36-
// When
37-
let url = URL.validURLFromString(from: raw)
38-
39-
// Then
40-
XCTAssertNotNil(url)
41-
XCTAssertEqual(url?.scheme, "https")
42-
XCTAssertEqual(url?.host, "example.com")
43-
XCTAssertEqual(url?.path, "/path")
44-
}
45-
4632
func testTrimsWhitespace() {
4733
let raw = " https://example.com/video.m3u8 "
4834
let url = URL.validURLFromString(from: raw)
@@ -86,9 +72,4 @@ final class testURL: XCTestCase {
8672
XCTAssertNil(URL.validURLFromString(from: "https://"))
8773
XCTAssertNil(URL.validURLFromString(from: "https:///path-only"))
8874
}
89-
90-
func testNoAutoSchemeOption() {
91-
// When auto-scheme is disabled, a bare host should fail.
92-
XCTAssertNil(URL.validURLFromString(from: "example.com", assumeHTTPSIfMissing: false))
93-
}
9475
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /