Skip to content

Commit

Permalink
Error displayed for incorrect URL #478
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Oct 13, 2024
1 parent f12a92d commit d10fc7d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/components/HrefActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ export default {
},
canShow() {
// We need to know the type, otherwise we don't even try to show it
if (typeof this.data.type !== 'string') {
if (typeof this.data?.type !== 'string') {
return false;
}
// If the tile renderer is a tile server, we can't really know what it supports so we pass all images
else if (this.tileRendererType === 'server' && imageMediaTypes.includes(this.data.type)) {
else if (this.tileRendererType === 'server' && imageMediaTypes.includes(this.data?.type)) {
return true;
}
// Don't pass GDAL VFS URIs to client-side tile renderer: https://github.com/radiantearth/stac-browser/issues/116
Expand All @@ -128,7 +128,7 @@ export default {
return false;
}
// Otherwise, all images that a browser can read are supported + JSON
else if (mapMediaTypes.includes(this.data.type)) {
else if (mapMediaTypes.includes(this.data?.type)) {
return true;
}
return false;
Expand Down Expand Up @@ -239,7 +239,7 @@ export default {
if (Utils.canBrowserDisplayImage(this.data)) {
return true;
}
else if (typeof this.data.type === 'string') {
else if (typeof this.data?.type === 'string') {
switch(this.data.type.toLowerCase()) {
case 'text/html':
case 'application/xhtml+xml':
Expand Down
2 changes: 1 addition & 1 deletion src/components/StacHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default {
else if (this.data.isCatalog()) {
return this.$tc(`stacCatalog`);
}
else {
else if (Utils.hasText(this.data.type)) {
return this.data.type;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/models/stac.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class STAC {
this[key] = data[key];
}
}
if (!Utils.hasText(this.type)) {
throw new Error('Not a valid STAC data source (no `type` present)');
}
}

isPotentiallyIncomplete() {
Expand Down
8 changes: 7 additions & 1 deletion src/views/Catalog.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div :class="{cc: true, [data.type.toLowerCase()]: true, mixed: hasCatalogs && hasItems, empty: !hasCatalogs && !hasItems}" :key="data.id">
<div :class="{cc: true, [cssStacType]: true, mixed: hasCatalogs && hasItems, empty: !hasCatalogs && !hasItems}" :key="data.id">
<b-row>
<b-col class="meta">
<section class="intro">
Expand Down Expand Up @@ -137,6 +137,12 @@ export default {
computed: {
...mapState(['data', 'url', 'apiItems', 'apiItemsLink', 'apiItemsPagination', 'nextCollectionsLink', 'stateQueryParameters']),
...mapGetters(['additionalLinks', 'catalogs', 'collectionLink', 'isCollection', 'items', 'getApiItemsLoading', 'parentLink', 'rootLink']),
cssStacType() {
if (Utils.hasText(this.data?.type)) {
return this.data?.type.toLowerCase();
}
return null;
},
showFilters() {
return Boolean(this.stateQueryParameters['itemFilterOpen']);
},
Expand Down

0 comments on commit d10fc7d

Please sign in to comment.