mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +03:00
c37de311ea
- The data/validation module is made up of several loosely related things with lots of dependencies - Separating out the various components makes it possible to see what's what, and importantly what has complex dependencies - validator + validate probably go togetheri in an external module, the other two files should probably have their own homes in related areas of ghost e.g. schema -> data/schema/validate.js
20 lines
1000 B
JavaScript
20 lines
1000 B
JavaScript
const should = require('should');
|
|
|
|
const validation = require('../../../../core/server/data/validation');
|
|
|
|
describe('Validator dependency', function () {
|
|
const validator = validation.validator;
|
|
|
|
it('isEmptyOrUrl filters javascript urls', function () {
|
|
validator.isEmptyOrURL('javascript:alert(0)').should.be.false();
|
|
validator.isEmptyOrURL('http://example.com/lol/<script>lalala</script>/').should.be.false();
|
|
validator.isEmptyOrURL('http://example.com/lol?somequery=<script>lalala</script>').should.be.false();
|
|
validator.isEmptyOrURL('').should.be.true();
|
|
validator.isEmptyOrURL('http://localhost:2368').should.be.true();
|
|
validator.isEmptyOrURL('http://example.com/test/').should.be.true();
|
|
validator.isEmptyOrURL('http://www.example.com/test/').should.be.true();
|
|
validator.isEmptyOrURL('http://example.com/foo?somequery=bar').should.be.true();
|
|
validator.isEmptyOrURL('example.com/test/').should.be.true();
|
|
});
|
|
});
|