Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
b9e81396
Unverified
Commit
b9e81396
authored
Jul 05, 2022
by
Zach Pomerantz
Committed by
GitHub
Jul 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: alter headers on cached response (#4032)
* fix: alter headers on cached response * test: deflake
parent
c82dcabd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
4 deletions
+6
-4
swap.test.ts
cypress/e2e/swap.test.ts
+1
-1
document.ts
src/serviceWorker/document.ts
+5
-3
No files found.
cypress/e2e/swap.test.ts
View file @
b9e81396
describe
(
'
Swap
'
,
()
=>
{
describe
(
'
Swap
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
cy
.
visit
(
'
/swap
'
)
cy
.
visit
(
'
/swap
'
)
.
get
(
'
#swap-currency-input .token-amount-input
'
)
})
})
it
(
'
starts with ETH selected by default
'
,
()
=>
{
it
(
'
starts with ETH selected by default
'
,
()
=>
{
...
...
src/serviceWorker/document.ts
View file @
b9e81396
...
@@ -98,12 +98,14 @@ export class CachedDocument extends Response {
...
@@ -98,12 +98,14 @@ export class CachedDocument extends Response {
static
async
from
(
response
:
Response
)
{
static
async
from
(
response
:
Response
)
{
const
text
=
await
response
.
text
()
const
text
=
await
response
.
text
()
// Some browsers (Android 12; Chrome 91) duplicate the content-type header, invalidating it.
// Set the content-type explicitly. Some browsers (Android 12; Chrome 91) use an invalid content-type header.
response
.
headers
.
set
(
'
Content-Type
'
,
'
text/html; charset=utf-8
'
)
const
headers
=
new
Headers
(
response
.
headers
)
headers
.
set
(
'
Content-Type
'
,
'
text/html; charset=utf-8
'
)
const
init
=
{
...
response
,
headers
}
// Injects a marker into the document so that client code knows it was served from cache.
// Injects a marker into the document so that client code knows it was served from cache.
// The marker should be injected immediately in the <body> so it is available to client code.
// The marker should be injected immediately in the <body> so it is available to client code.
return
new
CachedDocument
(
text
.
replace
(
'
<body>
'
,
'
<body><script>window.__isDocumentCached=true</script>
'
),
response
)
return
new
CachedDocument
(
text
.
replace
(
'
<body>
'
,
'
<body><script>window.__isDocumentCached=true</script>
'
),
init
)
}
}
private
constructor
(
text
:
string
,
response
:
Response
)
{
private
constructor
(
text
:
string
,
response
:
Response
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment