Skip to content

Commit 9fbb03c

Browse files
committed
Auto merge of #4314 - Turbo87:fix-back-link, r=Turbo87
catch-all: Fix broken "Go back" and "Reload" links > Refused to run the JavaScript URL because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' 'sha256-n1+BB7Ckjcal1Pr7QNBh/dKRTtBQsIytFodRiIosXdE='". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. Note that hashes do not apply to event handlers, style attributes and javascript: navigations unless the 'unsafe-hashes' keyword is present. This PR fixes the above error, that is triggered from hitting the "Go back" link on e.g. https://crates.io/crates/jdfgkjsdfjksnd
2 parents 77bfde0 + a21b0a2 commit 9fbb03c

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

app/controllers/catch-all.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ import Controller from '@ember/controller';
22
import { action } from '@ember/object';
33

44
export default class CatchAllController extends Controller {
5-
@action reload(event) {
6-
event.preventDefault();
5+
@action reload() {
76
this.model.transition.retry();
87
}
8+
9+
@action back() {
10+
history.back();
11+
}
912
}

app/styles/application.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ h1 {
5757
}
5858
}
5959

60-
a {
60+
a, .link {
6161
color: var(--link-color);
6262
text-decoration: none;
63+
cursor: pointer;
6364

6465
&:hover {
6566
color: var(--link-hover-color);

app/styles/catch-all.module.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
}
1616

1717
.link {
18+
composes: button-reset from '../styles/shared/buttons.module.css';
19+
composes: link from '../styles/application.module.css';
1820
font-weight: 500;
1921
}

app/templates/catch-all.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<h1 local-class="title" data-test-title>{{or @model.title "Page not found"}}</h1>
66

77
{{#if @model.tryAgain}}
8-
<a href="javascript:location.reload()" local-class="link" data-test-try-again {{on "click" this.reload}}>Try Again</a>
8+
<button type="button" local-class="link" data-test-try-again {{on "click" this.reload}}>Try Again</button>
99
{{else}}
10-
<a href="javascript:history.back()" local-class="link" data-test-go-back>Go Back</a>
10+
<button type="button" local-class="link" data-test-go-back {{on "click" this.back}}>Go Back</button>
1111
{{/if}}
1212
</div>
1313
</div>

0 commit comments

Comments
 (0)