mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-01 23:02:26 +00:00
fix(win32): normalize paths at permission boundaries (#14738)
This commit is contained in:
@@ -18,7 +18,7 @@ export async function assertExternalDirectory(ctx: Tool.Context, target?: string
|
||||
|
||||
const kind = options?.kind ?? "file"
|
||||
const parentDir = kind === "directory" ? target : path.dirname(target)
|
||||
const glob = path.join(parentDir, "*")
|
||||
const glob = path.join(parentDir, "*").replaceAll("\\", "/")
|
||||
|
||||
await ctx.ask({
|
||||
permission: "external_directory",
|
||||
|
||||
@@ -2,6 +2,8 @@ import { sortBy, pipe } from "remeda"
|
||||
|
||||
export namespace Wildcard {
|
||||
export function match(str: string, pattern: string) {
|
||||
if (str) str = str.replaceAll("\\", "/")
|
||||
if (pattern) pattern = pattern.replaceAll("\\", "/")
|
||||
let escaped = pattern
|
||||
.replace(/[.+^${}()|[\]\\]/g, "\\$&") // escape special regex chars
|
||||
.replace(/\*/g, ".*") // * becomes .*
|
||||
@@ -13,7 +15,8 @@ export namespace Wildcard {
|
||||
escaped = escaped.slice(0, -3) + "( .*)?"
|
||||
}
|
||||
|
||||
return new RegExp("^" + escaped + "$", "s").test(str)
|
||||
const flags = process.platform === "win32" ? "si" : "s"
|
||||
return new RegExp("^" + escaped + "$", flags).test(str)
|
||||
}
|
||||
|
||||
export function all(input: string, patterns: Record<string, any>) {
|
||||
|
||||
Reference in New Issue
Block a user