mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
29da6b24db
* Fixes issue where XSS scripts attacks were possible via the URL * Fix error * Move throwing error up * Add specs and make regex cover more xss cases
17 lines
633 B
JavaScript
17 lines
633 B
JavaScript
var isURLSameOrigin = require('../../../lib/helpers/isURLSameOrigin');
|
|
|
|
describe('helpers::isURLSameOrigin', function () {
|
|
it('should detect same origin', function () {
|
|
expect(isURLSameOrigin(window.location.href)).toEqual(true);
|
|
});
|
|
|
|
it('should detect different origin', function () {
|
|
expect(isURLSameOrigin('https://github.com/axios/axios')).toEqual(false);
|
|
});
|
|
|
|
it('should detect XSS scripts on a same origin request', function () {
|
|
expect(() => { isURLSameOrigin('https://github.com/axios/axios?<script>alert("hello")</script>'); })
|
|
.toThrowError(Error, 'URL contains XSS injection attempt')
|
|
})
|
|
});
|