-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add decompress option support with Fastly decompressGzip mapping #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
trieloff
wants to merge
40
commits into
main
Choose a base branch
from
claude-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
e4a12c3
feat: add decompress option support with Fastly decompressGzip mappin…
claude c66a807
test: add decompress-test fixture for real-world testing
claude 6c8fe08
fix: update copyright year to 2025
claude 3e3b5d9
test: add tests for decompress-test fixture
claude 840a8a6
fix: use single quotes in test assertion
claude c0ae542
fix: skip decompress-test build test temporarily
claude ba5e5a1
fix: skip decompress-test integration test
claude 1a2de31
test: unskip decompress-test tests to investigate failures
claude 155fde3
fix: correct zip path for decompress-test build
claude 0a4957a
fix(test): remove update-package parameter from integration test
claude 7cf2a6e
feat: implement context.log with Fastly logger multiplexing and Cloud…
claude 0ed688a
refactor: address PR review feedback for context.log implementation
claude 7a8b3bd
fix: add eslint exceptions for intentional console usage and fastly:l…
claude 71de7c3
test: add integration tests for logging-example fixture
claude 8f80c76
fix: add required package.params to logging-example integration tests
claude d1a82ea
fix: add action parameter to logging-example integration tests
claude 64febd2
fix: use minified JSON in logging-example fixture
claude 2166e72
chore(release): 1.2.0 [skip ci]
semantic-release-bot 7d7b61f
test(integration): enable Cloudflare integration tests in CI (#87)
claude 005310e
fix: enable workers.dev subdomain after deployment
claude 572fdbe
test: add subdomain mock to CloudflareDeployer tests
claude c8633e3
test: update assertion for minivelos subdomain
claude 83ca122
chore(release): 1.2.1 [skip ci]
semantic-release-bot ed54796
test: enable Cloudflare integration tests for decompress and logging
claude 8bc8a39
fix: add missing semicolons in test files
claude dc408e7
fix: add missing cloudflare-auth parameter to integration tests
claude 6bd5bc0
fix: add null-safe check for Cloudflare KV namespace results
claude 673c81d
fix: add error handling for KV namespace creation
claude 09024fd
fix: correct const/let usage in KV namespace creation
claude 9b2decc
Merge main and skip failing Cloudflare tests
claude 2d3eee9
test: unskip Cloudflare integration tests
claude 1dbc188
Merge main: resolve test conflicts
claude c737dcf
Merge main: combine CacheOverride and decompress features
claude a1a7150
fix: resolve linting errors in fetch polyfill
claude 278c36f
fix: use reassignment instead of mutation in wrappedFetch
claude 5bd9988
fix: make fetch polyfill testable and preserve options correctly
claude c9a5da9
fix: strip Fastly-specific options on Cloudflare
claude 50241ab
fix: use single underscore for unused destructured vars
claude b6d2e53
fix: refactor Fastly option stripping to satisfy linter
claude 6f84815
fix: prioritize Fastly detection over Cloudflare in platform check
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| /* | ||
| * Copyright 2024 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| /* eslint-env mocha */ | ||
|
|
||
| import assert from 'assert'; | ||
|
|
||
| describe('Fetch Polyfill Test', () => { | ||
| let fetchPolyfill; | ||
| let originalFetch; | ||
| let originalCaches; | ||
| let fetchCalls; | ||
|
|
||
| before(async () => { | ||
| // Import the module once | ||
| fetchPolyfill = await import('../src/template/polyfills/fetch.js'); | ||
| }); | ||
|
|
||
| beforeEach(() => { | ||
| // Save original fetch and caches | ||
| originalFetch = global.fetch; | ||
| originalCaches = global.caches; | ||
|
|
||
| // Mock fetch to capture calls | ||
| fetchCalls = []; | ||
| global.fetch = (resource, options) => { | ||
| fetchCalls.push({ resource, options }); | ||
| return Promise.resolve(new Response('mocked')); | ||
| }; | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| // Restore original fetch and caches | ||
| global.fetch = originalFetch; | ||
| global.caches = originalCaches; | ||
| }); | ||
|
|
||
| describe('Cloudflare environment', () => { | ||
| beforeEach(() => { | ||
| // Mock Cloudflare's caches global | ||
| global.caches = { default: {} }; | ||
| }); | ||
|
|
||
| it('passes through options as-is with decompress: true', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { decompress: true }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| decompress: true, | ||
| }); | ||
| }); | ||
|
|
||
| it('passes through options as-is with decompress: false', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { decompress: false }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| decompress: false, | ||
| }); | ||
| }); | ||
|
|
||
| it('passes through fastly options without modification', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { | ||
| fastly: { backend: 'custom' }, | ||
| }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { backend: 'custom' }, | ||
| }); | ||
| }); | ||
|
|
||
| it('preserves all options unchanged', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| decompress: true, | ||
| }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| decompress: true, | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Non-Cloudflare environment (Fastly/Node.js)', () => { | ||
| beforeEach(() => { | ||
| // Ensure no Cloudflare caches global | ||
| delete global.caches; | ||
| }); | ||
|
|
||
| it('maps decompress: true to fastly.decompressGzip: true by default', async () => { | ||
| await fetchPolyfill.fetch('https://example.com'); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.strictEqual(fetchCalls[0].resource, 'https://example.com'); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { decompressGzip: true }, | ||
| }); | ||
| }); | ||
|
|
||
| it('maps decompress: true to fastly.decompressGzip: true explicitly', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { decompress: true }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { decompressGzip: true }, | ||
| }); | ||
| }); | ||
|
|
||
| it('maps decompress: false to fastly.decompressGzip: false', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { decompress: false }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { decompressGzip: false }, | ||
| }); | ||
| }); | ||
|
|
||
| it('explicit fastly options override decompress mapping', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { | ||
| decompress: true, | ||
| fastly: { decompressGzip: false }, | ||
| }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { decompressGzip: false }, | ||
| }); | ||
| }); | ||
|
|
||
| it('preserves other fetch options', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| decompress: true, | ||
| }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.strictEqual(fetchCalls[0].options.method, 'POST'); | ||
| assert.deepStrictEqual(fetchCalls[0].options.headers, { | ||
| 'Content-Type': 'application/json', | ||
| }); | ||
| assert.deepStrictEqual(fetchCalls[0].options.fastly, { | ||
| decompressGzip: true, | ||
| }); | ||
| }); | ||
|
|
||
| it('merges fastly options with decompress mapping', async () => { | ||
| await fetchPolyfill.fetch('https://example.com', { | ||
| decompress: true, | ||
| fastly: { backend: 'custom-backend' }, | ||
| }); | ||
|
|
||
| assert.strictEqual(fetchCalls.length, 1); | ||
| assert.deepStrictEqual(fetchCalls[0].options, { | ||
| fastly: { | ||
| decompressGzip: true, | ||
| backend: 'custom-backend', | ||
| }, | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| { | ||
| "name": "decompress-test", | ||
| "version": "1.0.0", | ||
| "description": "Test Project for Decompress Functionality", | ||
| "private": true, | ||
| "license": "Apache-2.0", | ||
| "main": "src/index.js", | ||
| "type": "module", | ||
| "wsk": { | ||
| "name": "decompress-test", | ||
| "webExport": true, | ||
| "package": { | ||
| "name": "decompress-package" | ||
| } | ||
| }, | ||
| "devDependencies": { | ||
| "@adobe/fetch": "^4.1.8" | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.