Skip to content

Commit 49875b2

Browse files
authored
fix(packages): validate blank url and remove invalid format checks (#721)
Closes: MODKBEKBJ-863
1 parent f69fbbe commit 49875b2

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎NEWS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Remove HTML validation for package's custom display name field ([MODKBEKBJ-855](https://folio-org.atlassian.net/browse/MODKBEKBJ-855))
1414
* Add access types to eholdings/providers/{id}/packages response ([MODKBEKBJ-839](https://folio-org.atlassian.net/browse/MODKBEKBJ-839))
1515
* Sanitize HTML content for the package description field ([MODKBEKBJ-860](https://folio-org.atlassian.net/browse/MODKBEKBJ-860))
16+
* Validate blank package url and remove invalid format checks ([MODKBEKBJ-863](https://folio-org.atlassian.net/browse/MODKBEKBJ-863))
1617

1718
### Bug fixes
1819
* Fix offset handling when retrieving holdings from HoldingsIQ. ([MODKBEKBJ-825](https://folio-org.atlassian.net/browse/MODKBEKBJ-825))

‎src/main/java/org/folio/rest/validator/packages/PackageCustomAttributesValidator.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ private void validateUrl(String url) {
5858
if (url == null) {
5959
return;
6060
}
61+
ValidatorUtil.checkIsNotBlank("url", url);
6162
ValidatorUtil.checkMaxLength("url", url, MAX_URL_LENGTH);
62-
ValidatorUtil.checkUrlFormat("url", url);
6363
}
6464

6565
private void validateCustomCoverage(Coverage coverage) {

‎src/test/java/org/folio/rest/validator/packages/PackageCustomAttributesValidatorTest.java‎

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,17 @@ void shouldNotThrowWhenUrlIsValid() {
127127
}
128128

129129
@Test
130-
void shouldThrowWhenUrlHasNoProtocol() {
131-
var customAttributes = withUrl("example.com");
132-
assertThrows(InputValidationException.class, () -> validator.validate(customAttributes));
130+
void shouldNotThrowWhenUrlIsNull() {
131+
var customAttributes = withUrl(null);
132+
assertDoesNotThrow(() -> validator.validate(customAttributes));
133133
}
134134

135135
@Test
136-
void shouldThrowWhenUrlIsInvalidFormat() {
137-
var customAttributes = withUrl("not a url");
136+
void shouldThrowWhenUrlIsBlank() {
137+
var customAttributes = withUrl(" ");
138138
assertThrows(InputValidationException.class, () -> validator.validate(customAttributes));
139139
}
140140

141-
@Test
142-
void shouldNotThrowWhenUrlIsNull() {
143-
var customAttributes = withUrl(null);
144-
assertDoesNotThrow(() -> validator.validate(customAttributes));
145-
}
146-
147141
@Test
148142
void shouldNotThrowWhenCustomCoverageIsNull() {
149143
var customAttributes = withCoverage(null);

0 commit comments

Comments
 (0)