This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 6827353 Make hyphen capture groups optional, not repeating (#6410)
6827353 is described below
commit 68273536e27eca83adb0c323f2b74b4dac1c39ae
Author: Zach Hoffman <[email protected]>
AuthorDate: Thu Jan 13 22:38:52 2022 -0800
Make hyphen capture groups optional, not repeating (#6410)
---
.../new-delivery-service.component.spec.ts | 10 ++++++++++
.../new-delivery-service/new-delivery-service.component.ts | 2 +-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git
a/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.spec.ts
b/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.spec.ts
index 313b1e0..215705f 100644
---
a/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.spec.ts
+++
b/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.spec.ts
@@ -137,4 +137,14 @@ describe("NewDeliveryServiceComponent", () => {
// component.cdnObject.setValue({ name: 'testCDN', id: 1 } as CDN);
// component.dsType.setValue({ name: 'testType', id: 1 } as Type);
// });
+
+ it("should match hostnames", async () => {
+ const invalidHostnames: Array<string> = ["h.", "h-", "h-.o",
"-h.o"];
+ invalidHostnames.forEach((invalidHostname: string) => void
expect(() => component.setDNSBypass(invalidHostname)).toThrow());
+ const validHostnames: Array<string> = ["h", "h.o.s.T.n.a.m.e",
"h-O-------s.tNaMe"];
+ expect(() => validHostnames.forEach((hostname: string) => {
+ component.setDNSBypass(hostname);
+
expect(component.deliveryService.dnsBypassCname).toBe(hostname);
+ })).not.toThrow();
+ });
});
diff --git
a/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.ts
b/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.ts
index 793b39b..9c7a529 100644
---
a/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.ts
+++
b/experimental/traffic-portal/src/app/core/new-delivery-service/new-delivery-service.component.ts
@@ -53,7 +53,7 @@ const VALID_IPV6 =
/^((((((([\da-fA-F]{1,4})):){6})((((([\da-fA-F]{1,4})):(([\da
/**
* A regular expression that matches a valid hostname
*/
-const VALID_HOSTNAME =
/^[A-z\d]([A-z0-9\-]*[A-z0-9])*(\.[A-z\d]([A-z0-9\-]*[A-z0-9])*)*$/;
+const VALID_HOSTNAME =
/^[A-z\d]([A-z0-9\-]*[A-z0-9])?(\.[A-z\d]([A-z0-9\-]*[A-z0-9])?)*$/;
/**
* NewDeliveryServiceComponent is the controller for the new Delivery Service