Skip to content

Commit 61f8a5c

Browse files
committed
fix(globs): InvalidPathException in matchesGlobs (#124)
1 parent 943e959 commit 61f8a5c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
- Prevent `InvalidPathException` being raised in `GitlabLintUtils.matchesGlobs`.
7+
58
## [1.13.0] - 2023-05-18
69

710
### Added

src/main/kotlin/com/github/blarc/gitlab/template/lint/plugin/GitlabLintUtils.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import com.intellij.openapi.project.Project
1111
import com.intellij.openapi.vfs.VirtualFile
1212
import com.intellij.openapi.wm.WindowManager
1313
import java.nio.file.FileSystems
14+
import java.nio.file.InvalidPathException
1415

1516
object GitlabLintUtils {
1617
fun isGitlabYaml(file: VirtualFile): Boolean {
@@ -40,8 +41,11 @@ object GitlabLintUtils {
4041
val fileSystem = FileSystems.getDefault()
4142
for (globString in globs) {
4243
val glob = fileSystem.getPathMatcher("glob:$globString")
43-
if (glob.matches(fileSystem.getPath(text))) {
44-
return true
44+
try {
45+
return glob.matches(fileSystem.getPath(text))
46+
}
47+
catch (e: InvalidPathException) {
48+
return false
4549
}
4650
}
4751
return false

0 commit comments

Comments
 (0)