SwiftTailwind/Plugins/TailwindCSS/Utils.swift
laosb 8359d795eb Improve source file detection and tests
- Use SwiftPM-provided sourceFiles for filtering - Add Utils.swift with
URL descendant check - Update example to use Views/ instead of Folder/ -
Add test for non-included Swift file - Update .zed settings to disable
VSCode CSS language server
2025-08-20 21:01:17 +08:00

24 lines
524 B
Swift

import Foundation
extension URL {
func isOrIsDescendant(of ancestor: URL) -> Bool {
guard ancestor.isFileURL, self.isFileURL else {
return false
}
let ancestorComponents = ancestor.pathComponents
let selfComponents = self.pathComponents
guard selfComponents.count >= ancestorComponents.count else {
return false
}
for (index, component) in ancestorComponents.enumerated() {
if selfComponents[index] != component {
return false
}
}
return true
}
}