Skip to content

Commit c1d16e9

Browse files
committed
Fix issue where s3 thumbnails were shown as browser-compatible radiantearth/stac-browser#668
1 parent 8dafc49 commit c1d16e9

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/reference.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { browserProtocols, toAbsolute } from './http.js';
22
import { cogMediaTypes, geotiffMediaTypes, isMediaType } from "./mediatypes.js";
33
import { hasText } from './utils.js';
44
import STACObject from './object.js';
5-
import URI from 'urijs';
65
import { browserImageTypes } from './mediatypes.js';
76

87
/**
@@ -68,9 +67,9 @@ class STACReference extends STACObject {
6867
else if (!allowUndefined && typeof this.type === 'undefined') {
6968
return false;
7069
}
71-
let uri = new URI(this.href);
72-
let protocol = uri.protocol().toLowerCase();
73-
let extension = uri.suffix().toLowerCase();
70+
const uri = this.getAbsoluteUrl(false);
71+
const protocol = uri.protocol().toLowerCase();
72+
const extension = uri.suffix().toLowerCase();
7473
if (hasText(protocol) && !browserProtocols.includes(protocol)) {
7574
return false;
7675
}

src/stac.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,17 @@ class STAC extends STACHypermedia {
8686
if (thumbnails.length === 0) {
8787
thumbnails = this.getLinks().filter(link => link.isPreview());
8888
}
89-
if (browserOnly) {
90-
// Remove all images that can't be displayed in a browser
91-
thumbnails = thumbnails.filter(img => img.canBrowserDisplayImage());
92-
}
9389
// Some old catalogs use just a asset key
9490
if (thumbnails.length === 0) {
9591
const thumbnail = this.getAsset("thumbnail");
9692
if (thumbnail) {
9793
thumbnails.push(thumbnail);
9894
}
9995
}
96+
if (browserOnly) {
97+
// Remove all images that can't be displayed in a browser
98+
thumbnails = thumbnails.filter(img => img.canBrowserDisplayImage());
99+
}
100100
if (prefer && thumbnails.length > 1) {
101101
// Prefer one role over the other.
102102
// The two step approach with two filters ensures the same sort bevahiour across all browsers:

0 commit comments

Comments
 (0)