Skip to content

Commit

Permalink
Code review: check version of fetched evalscript to avoid unnecessary…
Browse files Browse the repository at this point in the history
… conversion
  • Loading branch information
dgostencnik committed Apr 10, 2020
1 parent 7752df4 commit 1719195
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/layer/AbstractSentinelHubV3Layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ export class AbstractSentinelHubV3Layer extends AbstractLayer {
}
if (this.evalscriptUrl && !this.evalscript) {
const response = await axios.get(this.evalscriptUrl, { responseType: 'text', useCache: true });
const evalscriptV3 = await this.convertEvalscriptToV3(response.data);
let evalscriptV3;
//Check version of fetched evalscript by checking if first line starts with //VERSION=3
if (response.data.startsWith('//VERSION=3')) {
evalscriptV3 = response.data;
} else {
evalscriptV3 = await this.convertEvalscriptToV3(response.data);
}
this.evalscript = evalscriptV3;
}
if (!this.evalscript && !this.dataProduct) {
Expand Down

0 comments on commit 1719195

Please sign in to comment.