Skip to content

Commit

Permalink
Fix bug in response
Browse files Browse the repository at this point in the history
  • Loading branch information
CMEONE committed Mar 10, 2021
1 parent 4055a99 commit f61ef85
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 8 additions & 4 deletions tApp-service-worker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var version = 'v28::';
var version = 'v29::';

self.addEventListener("install", function(event) {
event.waitUntil(() => {
Expand Down Expand Up @@ -28,13 +28,15 @@ self.addEventListener("fetch", function(event) {
fetch(page).then((response) => {
resolve(response);
}).catch(() => {
resolve(new Response("", {
let res = new Response("", {
status: 500,
statusText: 'Service Unavailable',
headers: new Headers({
'Content-Type': 'text/html'
})
}));
});
Object.defineProperty(res, "url", {value: url});
resolve(res);
});
});
}
Expand Down Expand Up @@ -98,7 +100,9 @@ self.addEventListener("fetch", function(event) {
}
});
if(request.result != null) {
resolve(new Response(request.result.data, request.result.response));
let res = new Response(request.result.data, request.result.response);
Object.defineProperty(res, "url", {value: url});
resolve(res);
} else {
myFetch(url).then((response) => {
resolve(response);
Expand Down
6 changes: 4 additions & 2 deletions tApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class tApp {
static database;
static currentHash = "/";
static get version() {
return "v0.8.4";
return "v0.8.5";
}
static configure(params) {
if(params == null) {
Expand Down Expand Up @@ -309,7 +309,9 @@ class tApp {
}
});
if(!ignoreCache && cachedPage != null) {
resolve(new Response(cachedPage.data, cachedPage.response));
let res = new Response(cachedPage.data, cachedPage.response);
Object.defineProperty(res, "url", {value: fullPath});
resolve(res);
}
});
}
Expand Down

0 comments on commit f61ef85

Please sign in to comment.