File tree Expand file tree Collapse file tree
main/java/org/prebid/server/util
test/java/org/prebid/server/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,6 +125,12 @@ private static boolean containsMacrosses(String url) {
125125 }
126126
127127 public static String validateDomainName (String domainName ) {
128+ if (domainName == null ) {
129+ throw new PreBidException ("Domain name is null" );
130+ }
131+ if (domainName .isEmpty ()) {
132+ return domainName ;
133+ }
128134 if (!VALID_DOMAIN .matcher (domainName ).matches ()) {
129135 throw new PreBidException ("Domain name %s contains invalid characters" .formatted (domainName ));
130136 }
Original file line number Diff line number Diff line change @@ -71,6 +71,15 @@ public void validateDomainNameShouldReturnExpectedDomainName() {
7171 assertThat (HttpUtil .validateDomainName ("sub.domain-example.com" )).isEqualTo ("sub.domain-example.com" );
7272 assertThat (HttpUtil .validateDomainName ("127.0.0.1" )).isEqualTo ("127.0.0.1" );
7373 assertThat (HttpUtil .validateDomainName ("example.com:8080" )).isEqualTo ("example.com:8080" );
74+ assertThat (HttpUtil .validateDomainName ("" )).isEqualTo ("" );
75+ }
76+
77+ @ Test
78+ public void validateDomainNameShouldFailOnNull () {
79+ // when and then
80+ assertThatExceptionOfType (PreBidException .class )
81+ .isThrownBy (() -> HttpUtil .validateDomainName (null ))
82+ .withMessage ("Domain name is null" );
7483 }
7584
7685 @ Test
You can’t perform that action at this time.
0 commit comments