Skip to content

Commit

Permalink
fix: do not search recursively when a glob is a file name wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
fortmarek committed Nov 14, 2024
1 parent 34a58f2 commit 7c02c2d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Sources/Glob/GlobSearch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public struct MatchResult {
/// - skipHiddenFiles: When true, hidden files will not be returned.
/// - Returns: An async collection of urls.
@available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *)
// swiftlint:disable:next function_body_length
public func search(
// swiftformat:disable unusedArguments
directory baseURL: URL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath),
Expand Down Expand Up @@ -110,7 +111,17 @@ public func search(
case .pathWildcard:
return true
case .componentWildcard:
return index != include.sections.endIndex - 1
if index == include.sections.endIndex - 1 {
return false
} else if index == include.sections.endIndex - 2 {
if case let .constant(constant) = include.sections.last {
return constant.contains("/")
} else {
return true
}
} else {
return true
}
default:
return false
}
Expand Down

0 comments on commit 7c02c2d

Please sign in to comment.