Skip to content

Commit 09fc5a0

Browse files
CorieWcabljac
andauthored
feat(storage-resize-images): support '+' character in path (#2286)
* feat(storage-resize-images): support '+' character in path * chore(storage-resize-images): added test for '+' char in path * chore(storage-resize-images): bump extension version --------- Co-authored-by: Jacob Cable <jacobcable94@gmail.com>
1 parent b54d7df commit 09fc5a0

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

storage-resize-images/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 0.2.8
2+
3+
fixed - support '+' character in paths
4+
15
## Version 0.2.7
26

37
fixed - maintain aspect ratio of resized images (#2115)

storage-resize-images/extension.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515
name: storage-resize-images
16-
version: 0.2.7
16+
version: 0.2.8
1717
specVersion: v1beta
1818

1919
displayName: Resize Images

storage-resize-images/functions/__tests__/util.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,14 @@ describe("startsWithArray function for testing image path", () => {
4949
expect(allowResize).toBe(false);
5050
});
5151
});
52+
53+
it("can handle '+' when replacing '*' in globbed paths", () => {
54+
const allowed = ["/test/picture", "/test/*/picture"];
55+
const imagePaths = ["/test/picture", "/test/+/picture"];
56+
57+
imagePaths.forEach((path) => {
58+
let allowResize = startsWithArray(allowed, path);
59+
expect(allowResize).toBe(true);
60+
});
61+
});
5262
});

storage-resize-images/functions/src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const startsWithArray = (
88
for (let userPath of userInputPaths) {
99
const trimmedUserPath = userPath
1010
.trim()
11-
.replace(/\*/g, "([a-zA-Z0-9_\\-.\\s\\/]*)?");
11+
.replace(/\*/g, "([a-zA-Z0-9_\\-\\+.\\s\\/]*)?");
1212

1313
const regex = new RegExp("^" + trimmedUserPath + "(?:/.*|$)");
1414

0 commit comments

Comments
 (0)