Skip to content

Commit

Permalink
Merge pull request #3 from rizwankce/fix-linux-test
Browse files Browse the repository at this point in the history
Fix linux test
  • Loading branch information
nysander authored Sep 17, 2020
2 parents 5cc5179 + d00942b commit 35b3c77
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
macos:
runs-on: macOS-latest

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Build and Test
run: swift test
linux:
runs-on: ubuntu-latest

strategy:
matrix:
swift: ["5.2"]

container:
image: swift:${{ matrix.swift }}

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Build
run: swift build
- name: Test
run: swift test --enable-test-discovery
16 changes: 11 additions & 5 deletions Sources/UnicodeURL/String+Unicode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ extension String {
var pendingSurrogateHigh = false

for index in 0..<length {
let c = buffer[index]
if CFStringIsSurrogateHighCharacter(unichar(c)) {
let c = unichar(truncatingIfNeeded: buffer[index])
if CFStringIsSurrogateHighCharacter(c) {
if pendingSurrogateHigh {
// Surrogate high after surrogate high
return false
} else {
pendingSurrogateHigh = true
}
} else if CFStringIsSurrogateLowCharacter(unichar(c)) {
} else if CFStringIsSurrogateLowCharacter(c) {
if pendingSurrogateHigh {
pendingSurrogateHigh = false
} else {
Expand Down Expand Up @@ -72,8 +72,7 @@ extension String {
var index = self.startIndex

while index != self.endIndex {
let set = CharacterSet(charactersIn: "\(self[index])")
if chars.isSuperset(of: set) {
if chars.contains(self[index]) {
break
}
index = self.index(index, offsetBy: 1)
Expand All @@ -85,3 +84,10 @@ extension String {
]
}
}

extension CharacterSet {
func contains(_ character: Character) -> Bool {
let string = String(character)
return string.rangeOfCharacter(from: self, options: [], range: string.startIndex..<string.endIndex) != nil
}
}

0 comments on commit 35b3c77

Please sign in to comment.