3 ms·
$domain =~ s/\.\s+$//; This will chop off a trailing dot and any white space that follows but not a trailing dot without trailing whitespace. Is that really th
by raldi 4y ago
$domain =~ s/\.\s+$//;
This will chop off a trailing dot and any white space that follows but not a trailing dot without trailing whitespace. Is that really the intent? Also, it will turn `domain.com.. ` into `domain.com.`
$domain =~ s/[^A-Za-z0-9.]+/-/g;
Won’t this change
my—-domain.com
into
my-domain.com
? Double dashes are particularly common in internationalized domain names (https://en.wikipedia.org/wiki/Internationalized_domain_name#Example_of_IDNA_encoding https://en.wikipedia.org/wiki/Internationalized_domain_name#...), and this mangles perfectly-valid ones.
- arjvik 4y agoI've got no idea why either regex would be useful, can anyone come up with a reason other than a bad attempt to sanitize input?