mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-17 21:40:39 -07:00
+1
-1
@@ -27,7 +27,7 @@ export class Loader {
|
||||
const rRelativePath = new RegExp(['.' + sep, '..' + sep, './', '../'].map(prefix => escapeRegex(prefix)).join('|'))
|
||||
this.shouldLoadRelative = (referencedFile: string) => rRelativePath.test(referencedFile)
|
||||
} else {
|
||||
this.shouldLoadRelative = (referencedFile: string) => false
|
||||
this.shouldLoadRelative = (_referencedFile: string) => false
|
||||
}
|
||||
this.contains = this.options.fs.contains || (() => true)
|
||||
}
|
||||
|
||||
+32
-19
@@ -2,25 +2,38 @@ import { MapFS } from './map-fs'
|
||||
|
||||
describe('MapFS', () => {
|
||||
const fs = new MapFS({})
|
||||
it('should resolve relative file paths', () => {
|
||||
expect(fs.resolve('foo/bar', 'coo', '')).toEqual('foo/bar/coo')
|
||||
describe('#resolve()', () => {
|
||||
it('should resolve relative file paths', () => {
|
||||
expect(fs.resolve('foo/bar', 'coo', '')).toEqual('foo/bar/coo')
|
||||
})
|
||||
it('should resolve to parent', () => {
|
||||
expect(fs.resolve('foo/bar', '../coo', '')).toEqual('foo/coo')
|
||||
})
|
||||
it('should resolve to root', () => {
|
||||
expect(fs.resolve('foo/bar', '../../coo', '')).toEqual('coo')
|
||||
})
|
||||
it('should resolve exceeding root', () => {
|
||||
expect(fs.resolve('foo/bar', '../../../coo', '')).toEqual('coo')
|
||||
})
|
||||
it('should resolve from absolute path', () => {
|
||||
expect(fs.resolve('/foo/bar', '../../coo', '')).toEqual('/coo')
|
||||
})
|
||||
it('should resolve exceeding root from absolute path', () => {
|
||||
expect(fs.resolve('/foo/bar', '../../../coo', '')).toEqual('/coo')
|
||||
})
|
||||
it('should resolve from invalid path', () => {
|
||||
expect(fs.resolve('foo//bar', '../coo', '')).toEqual('foo/coo')
|
||||
})
|
||||
it('should resolve current path', () => {
|
||||
expect(fs.resolve('foo/bar', '.././coo', '')).toEqual('foo/coo')
|
||||
})
|
||||
it('should resolve invalid path', () => {
|
||||
expect(fs.resolve('foo/bar', '..//coo', '')).toEqual('foo/coo')
|
||||
})
|
||||
})
|
||||
it('should resolve to parent', () => {
|
||||
expect(fs.resolve('foo/bar', '../coo', '')).toEqual('foo/coo')
|
||||
})
|
||||
it('should resolve to root', () => {
|
||||
expect(fs.resolve('foo/bar', '../../coo', '')).toEqual('coo')
|
||||
})
|
||||
it('should resolve exceeding root', () => {
|
||||
expect(fs.resolve('foo/bar', '../../../coo', '')).toEqual('coo')
|
||||
})
|
||||
it('should resolve from absolute path', () => {
|
||||
expect(fs.resolve('/foo/bar', '../../coo', '')).toEqual('/coo')
|
||||
})
|
||||
it('should resolve exceeding root from absolute path', () => {
|
||||
expect(fs.resolve('/foo/bar', '../../../coo', '')).toEqual('/coo')
|
||||
})
|
||||
it('should resolve from invalid path', () => {
|
||||
expect(fs.resolve('foo//bar', '../coo', '')).toEqual('foo/coo')
|
||||
describe('#.readFileSync()', () => {
|
||||
it('should throw if not exist', () => {
|
||||
expect(() => fs.readFileSync('foo/bar')).toThrow('NOENT: foo/bar')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user