The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/server/lib/fileUtils.tests.ts

28 lines
1.3 KiB

/* eslint-env mocha */
import { expect } from 'chai';
import { fileName, joinPath } from './fileUtils';
describe('File utils', () => {
it('should return a valid file name', () => {
expect(fileName('something')).to.equal('something');
expect(fileName('some@thing')).to.equal('some@thing');
expect(fileName('/something')).to.equal('something');
expect(fileName('/some/thing')).to.equal('some-thing');
expect(fileName('/some/thing/')).to.equal('some-thing');
expect(fileName('///some///thing///')).to.equal('some-thing');
expect(fileName('some/thing')).to.equal('some-thing');
expect(fileName('some:"thing"')).to.equal('some-thing');
expect(fileName('some:"thing".txt')).to.equal('some-thing-.txt');
expect(fileName('some"thing"')).to.equal('some-thing');
expect(fileName('some\u0000thing')).to.equal('some-thing');
});
it('should return a valid joined path', () => {
expect(joinPath('/app', 'some@thing')).to.equal('/app/some@thing');
expect(joinPath('../app', 'something')).to.equal('../app/something');
expect(joinPath('../app/', 'something')).to.equal('../app/something');
expect(joinPath('../app/', '/something')).to.equal('../app/something');
expect(joinPath('/app', '/something')).to.equal('/app/something');
expect(joinPath('/app', '/../some/thing')).to.equal('/app/..-some-thing');
});
});