rawlinp commented on a change in pull request #2314: Remove 
deliveryservice.org_server_fqdn column/compute it from Origin table
URL: https://github.com/apache/trafficcontrol/pull/2314#discussion_r195215795
 
 

 ##########
 File path: 
traffic_ops/traffic_ops_golang/deliveryservice/deliveryservicesv13.go
 ##########
 @@ -306,6 +312,88 @@ func createDefaultRegex(tx *sql.Tx, dsID int, xmlID 
string) error {
        return nil
 }
 
+func parseOrgServerFQDN(orgServerFQDN string) (*string, *string, *string, 
error) {
 
 Review comment:
   Yes, I tried to make this regex as simple as possible, so it basically 
allows anything that isn't `:` to be parsed as the FQDN here. However, the 
`url.Parse` function doesn't validate it much either from what I can tell 
(aside from your example which returns an error because it's looking for a 
matching `]` as if it were enclosing an IPv6 address). But that's where the 
validation in `validateOrgServerFQDN` comes in. Anything parsed as the FQDN 
here must pass the `isHost` validation there.
   
   And I disagree that regexes are always hard to read (especially this one). 
We're expecting a certain form of input pattern here, and I think a regex is 
the best tool for the job. If someone is having trouble understanding it, they 
can drop it into regex101.com and get a detailed description of the patterns 
and capture groups. The parentheses could even be removed to eliminate some of 
the obfuscation which makes it a relatively simple regex IMO.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to