返回 slidev
utils.test.ts
根目录 / packages / parser / src / utils.test.ts
1 import { describe, expect, it } from 'vitest'
2 import { isPathInsideRoots } from './fs'
3
4 describe('isPathInsideRoots', () => {
5 it('accepts a path nested inside a root', () => {
6 expect(isPathInsideRoots('/a/b/c', ['/a'])).toBe(true)
7 })
8
9 it('accepts a path that equals the root itself', () => {
10 expect(isPathInsideRoots('/a', ['/a'])).toBe(true)
11 })
12
13 it('rejects a path outside every root', () => {
14 expect(isPathInsideRoots('/x', ['/a'])).toBe(false)
15 })
16
17 it('rejects a `..`-escaping relative resolution', () => {
18 expect(isPathInsideRoots('/a/../x', ['/a'])).toBe(false)
19 })
20 })
21
21 lines TYPESCRIPT