Skip to content

Commit

Permalink
Allow 1-character Tag Names (cmseaton42#18)
Browse files Browse the repository at this point in the history
* Fix tag regex to allow 1-character tag names

Fix for cmseaton42#17

* adds a test for 1-characters numeric tag names

* Increments version
  • Loading branch information
patrickjmcd authored and cmseaton42 committed May 18, 2018
1 parent 764eea0 commit 495de2a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ethernet-ip",
"version": "1.1.6",
"version": "1.1.7",
"description": "A simple node interface for Ethernet/IP.",
"main": "./src/index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions src/tag/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class Tag extends EventEmitter {
this.emit("KeepAlive", this);
}
}

}
}

Expand Down Expand Up @@ -421,7 +421,7 @@ class Tag extends EventEmitter {
const tag = tagname.split(".");

const test = tag[tag.length - 1];
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*([a-zA-Z0-9_]|\[\d+\])$/i; // regex string to check for valid tagnames
const regex = /^[a-zA-Z_][a-zA-Z0-9_]*([a-zA-Z0-9_]*|\[\d+\])$/i; // regex string to check for valid tagnames
return typeof tagname === "string" && regex.test(test) && test.length <= 40;
}
// endregion
Expand Down
3 changes: 3 additions & 0 deletions src/tag/tag.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ describe("Tag Class", () => {
expect(fn(undefined)).toBeFalsy();
expect(fn(`hello${311}`)).toBeTruthy();
expect(fn("hello.how3")).toBeTruthy();
expect(fn("randy.julian.bubbles")).toBeTruthy();
expect(fn("a.b.c")).toBeTruthy();
expect(fn("1.1.1")).toBeFalsy();
expect(fn({ prop: "value" })).toBeFalsy();
expect(fn("fffffffffffffffffffffffffffffffffffffffff")).toBeFalsy();
expect(fn("ffffffffffffffffffffffffffffffffffffffff")).toBeTruthy();
Expand Down

0 comments on commit 495de2a

Please sign in to comment.