Skip to content

Commit

Permalink
fix url parser
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Sep 26, 2024
1 parent b76d7c4 commit 199a2e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions RootEncoder/Sources/RootEncoder/common/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,10 @@ public extension String {

func indexes(char: Character) -> [String.Index] {
var indexes = [String.Index]()
for index in indexes {
let c = self[index]
if c == char { indexes.append(index) }
for index in 0..<count {
let i = self.index(startIndex, offsetBy: index)
let c = self[i]
if c == char { indexes.append(i) }
}
return indexes
}
Expand Down
17 changes: 11 additions & 6 deletions RootEncoder/Tests/RootEncoderTests/RootEncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ import XCTest
@testable import RootEncoder

final class RootEncoderTests: XCTestCase {
func testExample() throws {
// XCTest Documentation
// https://developer.apple.com/documentation/xctest

// Defining Test Cases and Test Methods
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods
func testUrlParser() throws {
do {
let result = try UrlParser.parse(endpoint: "rtmp://a.rtmp.youtube.com/live2/xxxx-xxxx-xxxx-xxxx", requiredProtocols: ["rtmp"])
assert(result.host == "a.rtmp.youtube.com")
assert(result.getAppName() == "live2")
assert(result.getStreamName() == "xxxx-xxxx-xxxx-xxxx")
assert(result.scheme == "rtmp")
assert(result.getTcUrl() == "rtmp://a.rtmp.youtube.com/live2")
} catch {

}
}
}

0 comments on commit 199a2e3

Please sign in to comment.