diff --git a/fetch.js b/fetch.js index 06e4d1dc..d5bcef2d 100644 --- a/fetch.js +++ b/fetch.js @@ -338,6 +338,7 @@ export function Request(input, options) { this.mode = options.mode || this.mode || null this.signal = options.signal || this.signal this.referrer = null + this.cf = options.cf || {} if ((this.method === 'GET' || this.method === 'HEAD') && body) { throw new TypeError('Body not allowed for GET or HEAD requests') diff --git a/test/test.js b/test/test.js index 02119844..dbc37ef6 100644 --- a/test/test.js +++ b/test/test.js @@ -410,6 +410,11 @@ exercise.forEach(function(exerciseMode) { }) }) + test('construct with Cloudflare Request Attribute', function() { + var request = new Request('https://fetch.spec.whatwg.org/', {cf: {country: 'AUS'}}) + assert.equal(request.cf, {country: 'AUS'}) + }) + featureDependent(test, !nativeChrome, 'construct with used Request body', function() { var request1 = new Request('https://fetch.spec.whatwg.org/', { method: 'post',