Bug fix with wildcard.
This commit is contained in:
parent
8967338fae
commit
cfafaf0df9
@ -39,7 +39,7 @@ final class Glob {
|
|||||||
new AnyDirectoryHierarchy()
|
new AnyDirectoryHierarchy()
|
||||||
} else if (it.contains('*')) {
|
} else if (it.contains('*')) {
|
||||||
def replaced = it.replace([
|
def replaced = it.replace([
|
||||||
'*': '.',
|
'*': '.*',
|
||||||
'.': '\\.'
|
'.': '\\.'
|
||||||
])
|
])
|
||||||
new GlobFileOrDirectory(it, ~replaced)
|
new GlobFileOrDirectory(it, ~replaced)
|
||||||
@ -73,35 +73,29 @@ final class Glob {
|
|||||||
subjectParts = subject.split('/') as List<String>
|
subjectParts = subject.split('/') as List<String>
|
||||||
}
|
}
|
||||||
|
|
||||||
def subjectPartIter = subjectParts.iterator()
|
|
||||||
def subjectPartStack = new LinkedList<String>()
|
|
||||||
while (subjectPartIter.hasNext()) {
|
|
||||||
subjectPartStack.push(subjectPartIter.next())
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean result = true
|
boolean result = true
|
||||||
parts:
|
parts:
|
||||||
for (def part : this.parts) {
|
for (def part : this.parts) {
|
||||||
if (part instanceof Literal) {
|
if (part instanceof Literal) {
|
||||||
if (subjectPartStack.isEmpty()) {
|
if (subjectParts.isEmpty()) {
|
||||||
result = false
|
result = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
def subjectPart = subjectPartStack.pop()
|
def subjectPart = subjectParts.removeFirst()
|
||||||
if (part.literal != subjectPart) {
|
if (part.literal != subjectPart) {
|
||||||
result = false
|
result = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
} else if (part instanceof AnyDirectoryHierarchy) {
|
} else if (part instanceof AnyDirectoryHierarchy) {
|
||||||
while (!subjectPartStack.isEmpty()) {
|
while (!subjectParts.isEmpty()) {
|
||||||
def current = subjectPartStack.pop()
|
def current = subjectParts.removeFirst()
|
||||||
if (subjectPartStack.isEmpty()) {
|
if (subjectParts.isEmpty()) {
|
||||||
subjectPartStack.push(current)
|
subjectParts.push(current)
|
||||||
continue parts
|
continue parts
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (part instanceof GlobFileOrDirectory) {
|
} else if (part instanceof GlobFileOrDirectory) {
|
||||||
def subjectPart = subjectPartStack.pop()
|
def subjectPart = subjectParts.removeFirst()
|
||||||
def m = part.regexPattern.matcher(subjectPart)
|
def m = part.regexPattern.matcher(subjectPart)
|
||||||
if (!m.matches()) {
|
if (!m.matches()) {
|
||||||
result = false
|
result = false
|
||||||
|
Loading…
Reference in New Issue
Block a user