Skip to content

Commit f79f9c3

Browse files
committed
url now accepts boolean arguments.
1 parent 0bb447a commit f79f9c3

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
Nothing yet.
1111

12+
## [1.0.2] - 2025-04-28
13+
14+
### Fixed
15+
16+
- `url` now accepts boolean arguments.
17+
1218
## [1.0.1] - 2025-04-28
1319

1420
### Fixed
@@ -21,6 +27,7 @@ Nothing yet.
2127

2228
- Implemented Validator, message formatting and validation rules.
2329

24-
[unreleased]: https://github.com/Logitar/js/compare/v1.0.1...HEAD
30+
[unreleased]: https://github.com/Logitar/js/compare/v1.0.2...HEAD
31+
[1.0.2]: https://github.com/Logitar/js/compare/v1.0.1...v1.0.2
2532
[1.0.1]: https://github.com/Logitar/js/compare/v1.0.0...v1.0.1
2633
[1.0.0]: https://github.com/Logitar/js/releases/tag/v1.0.0

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "logitar-validation",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "JavaScript validation library distributed by Logitar.",
55
"keywords": [
66
"logitar",

src/rules/__tests__/url.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ describe("url", () => {
3232

3333
test.each([
3434
["", undefined],
35+
["", false],
3536
["http://example.com", undefined],
37+
["http://example.com", true],
3638
["http://example.com", "http,https"],
3739
["http://example.com", "http;https"],
3840
["https://example.com", "http|https"],

src/rules/url.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const url: ValidationRule = (value: unknown, args: unknown): RuleExecutionOutcom
2727
if (value.length > 0) {
2828
let isArgsValid: boolean = true;
2929
const protocols: Set<string> = new Set(["http", "https"]);
30-
if (typeof args !== "undefined") {
30+
if (typeof args !== "undefined" && typeof args !== "boolean") {
3131
let values: string[] = [];
3232
if (typeof args === "string") {
3333
values = args.split(/[,;\|]/);
@@ -37,6 +37,7 @@ const url: ValidationRule = (value: unknown, args: unknown): RuleExecutionOutcom
3737
if (values.length === 0) {
3838
isArgsValid = false;
3939
} else {
40+
protocols.clear();
4041
values.forEach((value) => protocols.add(format(value)));
4142
}
4243
}

0 commit comments

Comments
 (0)