mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-27 01:25:52 -05:00
Show NotAvailable for invalid URL
`/projects` without an id or `editor` should just show a 404.
This commit is contained in:
parent
4a57d36112
commit
880b890dc2
1 changed files with 3 additions and 2 deletions
|
@ -69,7 +69,7 @@ class Preview extends React.Component {
|
||||||
const pathname = window.location.pathname.toLowerCase();
|
const pathname = window.location.pathname.toLowerCase();
|
||||||
const parts = pathname.split('/').filter(Boolean);
|
const parts = pathname.split('/').filter(Boolean);
|
||||||
// parts[0]: 'projects'
|
// parts[0]: 'projects'
|
||||||
// parts[1]: either :id or 'editor'
|
// parts[1]: either :id or 'editor', invalid if neither specified
|
||||||
// parts[2]: undefined if no :id, otherwise either 'editor' or 'fullscreen'
|
// parts[2]: undefined if no :id, otherwise either 'editor' or 'fullscreen'
|
||||||
|
|
||||||
// Get single-comment id from url hash, using the #comments-{id} scheme from scratch2
|
// Get single-comment id from url hash, using the #comments-{id} scheme from scratch2
|
||||||
|
@ -81,6 +81,7 @@ class Preview extends React.Component {
|
||||||
addToStudioOpen: false,
|
addToStudioOpen: false,
|
||||||
extensions: [],
|
extensions: [],
|
||||||
favoriteCount: 0,
|
favoriteCount: 0,
|
||||||
|
invalidProject: parts.length === 1,
|
||||||
justShared: false,
|
justShared: false,
|
||||||
loveCount: 0,
|
loveCount: 0,
|
||||||
modInfo: {
|
modInfo: {
|
||||||
|
@ -448,7 +449,7 @@ class Preview extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
render () {
|
render () {
|
||||||
if (this.props.projectNotAvailable) {
|
if (this.props.projectNotAvailable || this.state.invalidProject) {
|
||||||
return (
|
return (
|
||||||
<Page>
|
<Page>
|
||||||
<div className="preview">
|
<div className="preview">
|
||||||
|
|
Loading…
Reference in a new issue