Skip to content

Commit

Permalink
[BREAKING] AbstractAdapter: Virtual base path must end with slash
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomByte committed Jun 13, 2022
1 parent 74594cf commit 6d1f411
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lib/adapters/AbstractAdapter.js
Expand Up @@ -27,6 +27,9 @@ class AbstractAdapter extends AbstractReaderWriter {
throw new TypeError("Class 'AbstractAdapter' is abstract");
}
super();
if (!virBasePath.endsWith("/")) {
throw new Error(`Virtual base path must end with a slash: ${virBasePath}`);
}
this._virBasePath = virBasePath;
this._virBaseDir = virBasePath.slice(0, -1);
this._excludes = excludes;
Expand Down
6 changes: 3 additions & 3 deletions test/lib/adapters/Memory_read.js
Expand Up @@ -62,7 +62,7 @@ test("glob resources from application.a w/o virtual base path prefix", async (t)
test("glob virtual directory w/o virtual base path prefix", async (t) => {
// TODO: Add similar test (globbing on empty directory) for FS RL
const readerWriter = resourceFactory.createAdapter({
virBasePath: "/app/one/two"
virBasePath: "/app/one/two/"
});

const resources = await readerWriter.byGlob("/*", {nodir: false});
Expand All @@ -72,7 +72,7 @@ test("glob virtual directory w/o virtual base path prefix", async (t) => {
test("glob virtual directory w/o virtual base path prefix and multiple patterns", async (t) => {
// TODO: Add similar test (globbing on empty directory) for FS RL
const readerWriter = resourceFactory.createAdapter({
virBasePath: "/app/one/two"
virBasePath: "/app/one/two/"
});

const resources = await readerWriter.byGlob([
Expand All @@ -94,7 +94,7 @@ test("glob virtual directory w/ virtual base path prefix", async (t) => {

test("glob virtual directory w/o virtual base path prefix and nodir: true", async (t) => {
const readerWriter = resourceFactory.createAdapter({
virBasePath: "/app/one/two"
virBasePath: "/app/one/two/"
});

const resources = await readerWriter.byGlob("/*", {nodir: true});
Expand Down

0 comments on commit 6d1f411

Please sign in to comment.