pax_global_header00006660000000000000000000000064124307344170014517gustar00rootroot0000000000000052 comment=27e9b96726b669e9594350585cc1e97474d3f995 has-cors-1.1.0/000077500000000000000000000000001243073441700132355ustar00rootroot00000000000000has-cors-1.1.0/.gitignore000066400000000000000000000000361243073441700152240ustar00rootroot00000000000000components build node_modules has-cors-1.1.0/History.md000066400000000000000000000005551243073441700152250ustar00rootroot00000000000000 1.1.0 / 2014-11-12 ================== * remove "global" module dependency (#2, @achingbrain) 1.0.2 / 2013-08-27 ================== * explicitly use `global` instead of being implicit * pin "component/global" to v2.0.1 1.0.1 / 2013-08-23 ================== * package: add "component" section 1.0.0 / 2013-08-22 ================== * Initial release has-cors-1.1.0/Makefile000066400000000000000000000002461243073441700146770ustar00rootroot00000000000000 build: components index.js @component build --dev components: component.json @component install --dev clean: rm -fr build components template.js .PHONY: clean has-cors-1.1.0/Readme.md000066400000000000000000000005421243073441700147550ustar00rootroot00000000000000 # has-cors Detects support for Cross-Origin Resource Sharing ## Installation Install with [component(1)](http://component.io): $ component install component/has-cors ## API Exports `true` if the user-agent supports CORS, or `false` otherwise. ``` js var hasCORS = require('has-cors'); console.log(hasCORS); // true ``` ## License MIT has-cors-1.1.0/component.json000066400000000000000000000004111243073441700161260ustar00rootroot00000000000000{ "name": "has-cors", "repo": "component/has-cors", "description": "Detects support for Cross-Origin Resource Sharing", "version": "1.1.0", "keywords": [], "development": {}, "license": "MIT", "main": "index.js", "scripts": [ "index.js" ] } has-cors-1.1.0/index.js000066400000000000000000000006141243073441700147030ustar00rootroot00000000000000 /** * Module exports. * * Logic borrowed from Modernizr: * * - https://github.com/Modernizr/Modernizr/blob/master/feature-detects/cors.js */ try { module.exports = typeof XMLHttpRequest !== 'undefined' && 'withCredentials' in new XMLHttpRequest(); } catch (err) { // if XMLHttp support is disabled in IE then it will throw // when trying to create module.exports = false; } has-cors-1.1.0/package.json000066400000000000000000000011551243073441700155250ustar00rootroot00000000000000{ "name": "has-cors", "version": "1.1.0", "description": "Detects support for Cross-Origin Resource Sharing", "main": "index.js", "repository": { "type": "git", "url": "git://github.com/component/has-cors.git" }, "keywords": [ "cors", "cross", "origin", "resource", "sharing", "domain" ], "author": "Nathan Rajlich (http://n8.io/)", "license": "MIT", "component": { "scripts": { "has-cors/index.js": "index.js" } }, "devDependencies": { "mocha": "^2.0", "chai": "^1.10" }, "scripts": { "test": "mocha" } } has-cors-1.1.0/test.js000066400000000000000000000007761243073441700145640ustar00rootroot00000000000000var expect = require('chai').expect; describe('has-cors', function() { beforeEach(function() { // make sure result is not cached delete require.cache[require.resolve('./')]; }); it('should not have cors', function() { var hasCors = require('./'); expect(hasCors).to.be.false; }); it('should have cors', function() { global.XMLHttpRequest = function() { this.withCredentials = true; }; var hasCors = require('./'); expect(hasCors).to.be.true; }); });