fix: Double recursive loops can cause server lockup on deeply nested docs (#5222)
This commit is contained in:
@@ -3,6 +3,7 @@ import parseImages from "./parseImages";
|
||||
it("should not return non images", () => {
|
||||
expect(parseImages(`# Header`).length).toBe(0);
|
||||
});
|
||||
|
||||
it("should return an array of images", () => {
|
||||
const result = parseImages(`# Header
|
||||
|
||||
@@ -11,9 +12,22 @@ it("should return an array of images", () => {
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toBe("/attachments/image.png");
|
||||
});
|
||||
|
||||
it("should return deeply nested images", () => {
|
||||
const result = parseImages(`# Header
|
||||
|
||||
- one
|
||||
- two
|
||||
- three 
|
||||
`);
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0]).toBe("/attachments/image.png");
|
||||
});
|
||||
|
||||
it("should not return non document links", () => {
|
||||
expect(parseImages(`[google](http://www.google.com)`).length).toBe(0);
|
||||
});
|
||||
|
||||
it("should not return non document relative links", () => {
|
||||
expect(parseImages(`[relative](/developers)`).length).toBe(0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user