| 77 | } |
| 78 | |
| 79 | checkPath(fileNameOrPath: string) { |
| 80 | if (this.isRootTopRath()) return true; |
| 81 | const destAbsolutePath = path.normalize(this.toAbsolutePath(fileNameOrPath)); |
| 82 | const topAbsolutePath = path.normalize(this.topPath); |
| 83 | |
| 84 | const destPath = destAbsolutePath.endsWith(path.sep) |
| 85 | ? destAbsolutePath.slice(0, -1) |
| 86 | : destAbsolutePath; |
| 87 | const topPath = topAbsolutePath.endsWith(path.sep) |
| 88 | ? topAbsolutePath.slice(0, -1) |
| 89 | : topAbsolutePath; |
| 90 | |
| 91 | this.assertInsideWorkspace(destPath); |
| 92 | |
| 93 | if (destPath.startsWith(topPath)) { |
| 94 | const parts = destPath.split(path.sep); |
| 95 | return topPath.split(path.sep).every((part, index) => { |
| 96 | return part === parts[index]; |
| 97 | }); |
| 98 | } |
| 99 | return false; |
| 100 | } |
| 101 | |
| 102 | assertInsideWorkspace(fileNameOrPath: string) { |
| 103 | const absPath = this.toAbsolutePath(fileNameOrPath); |