-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert Regex changes to hopefully fix GH Actions
Signed-off-by: Henrik Panhans <[email protected]>
- Loading branch information
1 parent
017ab5b
commit 052763b
Showing
4 changed files
with
18 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 12 additions & 3 deletions
15
Sources/SwiftFrameCore/Extensions/Collection+Extensions.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
import Foundation | ||
|
||
extension [URL] { | ||
extension Array where Element == URL { | ||
|
||
func filterByFileOrFoldername(regex: Regex<AnyRegexOutput>?) throws -> Self { | ||
func filterByFileOrFoldername(regex: NSRegularExpression?) throws -> Self { | ||
guard let regex else { | ||
return self | ||
} | ||
return self.filter { url in | ||
let lastComponent = url.deletingPathExtension().lastPathComponent | ||
return !lastComponent.matches(of: regex).isEmpty | ||
return regex.matches(lastComponent) | ||
} | ||
} | ||
|
||
} | ||
|
||
extension NSRegularExpression { | ||
|
||
func matches(_ string: String) -> Bool { | ||
let range = NSRange(location: 0, length: (string as NSString).length) | ||
return firstMatch(in: string, options: [], range: range) != nil | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters