Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
move serviceworker.js
  • Loading branch information
a1012112796 committed Apr 1, 2021
commit 23fbe1bf2deee21fca74c038f741c0219fbb0066
1 change: 0 additions & 1 deletion models/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,6 @@ var (
"template",
"user",
"favicon.ico",
"serviceworker.js",
}

reservedUserPatterns = []string{"*.keys", "*.gpg"}
Expand Down
7 changes: 1 addition & 6 deletions routers/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,12 @@ func GetUserByParams(ctx *context.Context) *models.User {
func Profile(ctx *context.Context) {
uname := ctx.Params(":username")

// Special handle for requests `favicon.ico` and `serviceworker.js`.
// Special handle for FireFox requests favicon.ico.
if uname == "favicon.ico" {
ctx.ServeFile(path.Join(setting.StaticRootPath, "public/img/favicon.png"))
return
}

if uname == "serviceworker.js" {
ctx.ServeFile(path.Join(setting.StaticRootPath, "public/serviceworker.js"))
return
}

if strings.HasSuffix(uname, ".png") {
ctx.Error(404)
return
Expand Down
2 changes: 1 addition & 1 deletion web_src/js/features/serviceworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default async function initServiceWorker() {
// the spec strictly requires it to be same-origin so it has to be AppSubUrl to work
await Promise.all([
checkCacheValidity(),
navigator.serviceWorker.register(`${AppSubUrl}/serviceworker.js`),
navigator.serviceWorker.register(`${AppSubUrl}/assets/serviceworker.js`),
]);
} catch (err) {
console.error(err);
Expand Down