Skip to content

Commit

Permalink
Allow << to be valid
Browse files Browse the repository at this point in the history
  • Loading branch information
bischofmax committed Feb 4, 2025
1 parent c1380ef commit dcf6826
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/utils/validation/containsOpeningTag.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const containsOpeningTagFollowedByString = (input: string): boolean => {
const regex = /<\S+/;
const regex = /<\S+(?<!<)/;
const result = regex.test(input);

return result;
Expand Down
22 changes: 20 additions & 2 deletions src/utils/validation/containsOpeningTag.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,27 @@ describe("containsOpeningTagFollowedByString", () => {
});
});

describe("when < is followed by a <", () => {
describe("when < followed by a < with a string", () => {
it("should return false", () => {
expect(containsOpeningTagFollowedByString("< <asd ")).toBe(true);
});
});

describe("when string contains two < followed by a string", () => {
it("should return true", () => {
expect(containsOpeningTagFollowedByString("<<")).toBe(true);
expect(containsOpeningTagFollowedByString("<asd <asd")).toBe(true);
});
});

describe("when < is followed by a <", () => {
it("should return false", () => {
expect(containsOpeningTagFollowedByString("<<")).toBe(false);
});
});

describe("when < is followed by a <", () => {
it("should return false", () => {
expect(containsOpeningTagFollowedByString("< <")).toBe(false);
});
});

Expand Down

0 comments on commit dcf6826

Please sign in to comment.