Skip to content

Commit

Permalink
Merge branch 'release/1.1.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddohler committed Oct 12, 2022
2 parents 43984a1 + 9507292 commit 2e2d914
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## UPCOMING

## 1.1.2 (2022-10-12)
- Allow users to specify a valid absolute URL when the default URL is invalid

## 1.1.1 (2022-09-30)
- Document bytes() method
- Fix production bundle not including unminified assets.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Although this function is called automatically by other functions, such as `loam
This function is safe to call multiple times.
#### Parameters
- `pathPrefix` (optional): The path or URL that Loam should use as a prefix when fetching its Web Worker. If left undefined, Loam will make a best guess based on the source path of its own `<script>` element. URLs with domains may be used to enable Loam to be loaded from CDNs like unpkg, but the file name should be left off.
- `pathPrefix` (optional): The path or URL that Loam should use as a prefix when fetching its Web Worker. If left undefined, Loam will make a best guess based on the source path of its own `<script>` element. If Loam has no `<script>` element (e.g. because you are using dynamic imports), then autodetecting a prefix will fail and this parameter must be provided. URLs with domains may be used to enable Loam to be loaded from CDNs like unpkg, but the file name should be left off.
- `gdalPrefix` (optional): The path or URL that Loam should use as a prefix when fetching WebAssembly assets for GDAL. If left undefined, Loam will use the same value as `pathPrefix`. URLs with domains may be used to enable loading from CDNs like unpkg, but the file name should be left off. If Loam fails to work properly and you see requests resulting in 404s or other errors for the `gdal.*` assets listed above, you will need to set `pathPrefix`, or this parameter, or both, to the correct locations where Loam can find those assets.
#### Return value
A promise that resolves when Loam is initialized. All of the functions described in this document wait for this promise's resolution when executing, so paying attention to whether this promise has resolved or not is not required. However, it may be helpful to do so in some circumstances, for example, if you want to display a visual indicator that your app is ready.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "loam",
"version": "1.1.1",
"version": "1.1.2",
"description": "Javascript wrapper for GDAL in the browser",
"main": "lib/loam.js",
"scripts": {
Expand Down
13 changes: 12 additions & 1 deletion src/workerCommunication.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,18 @@ const THIS_SCRIPT = _scripts[_scripts.length - 1];

// Inspired by Emscripten's method for doing the same thing
function getPathPrefix() {
return THIS_SCRIPT.src.substring(0, THIS_SCRIPT.src.lastIndexOf('/')) + '/';
const prefix = THIS_SCRIPT.src.substring(0, THIS_SCRIPT.src.lastIndexOf('/')) + '/';

try {
// prefix must be a valid URL so validate that it is before returning
// eslint-disable-next-line no-new
new URL(prefix);
return prefix;
} catch (error) {
// Returning undefined will require the user to specify a valid absolute URL for loamPrefix
// at least
return undefined;
}
}

// Destroy the worker and clear the promise so that calling initWorker will make a new one.
Expand Down
13 changes: 2 additions & 11 deletions test/loam.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ describe('Given that loam exists', () => {
.then((ds) => ds.transform())
.then((transform) => {
expect(transform).to.deep.equal([
-8380165.213197844,
2416.6666666666665,
0,
4886134.645645497,
0,
-2468.75,
-8380165.213197844, 2416.6666666666665, 0, 4886134.645645497, 0, -2468.75,
]);
});
});
Expand Down Expand Up @@ -240,11 +235,7 @@ describe('Given that loam exists', () => {
// Determined out-of-band by executing gdalwarp on the command line.
.then((transform) => {
expect(transform).to.deep.equal([
-75.2803049446235,
0.019340471787624117,
0.0,
40.13881222863268,
0.0,
-75.2803049446235, 0.019340471787624117, 0.0, 40.13881222863268, 0.0,
-0.019340471787624117,
]);
})
Expand Down

0 comments on commit 2e2d914

Please sign in to comment.