Regexp::Common qw /URI/ not allowing HTTPS



给我一个错误,不允许将HTTPS输入我们的一种形式之一。搜索表格后,我注意到我们正在使用Regexp :: Common QW/uri/

我尝试了

if ($params{URL} =~ /$RE{URI}{HTTP}{-keep}{-scheme}/)
{
$form{URL} = $1;
}
else
{
$error .= '<li>Website Address is invalid. The URL must be in this form: <b>http://example.com</b></li>';
}

这允许http和https,但仅保存://www.google.com到数据库

if ($params{URL} =~ /$RE{URI}{HTTP}{-keep}/)
{
$form{URL} = $1;
}
else
{
$error .= '<li>Website Address is invalid. The URL must be in this form: <b>http://example.com</b></li>';
}

仅允许HTTP,但将整个URL保存到数据库中

if ($params{URL} =~ /$RE{URI}{HTTP}{-scheme}/)
{
$form{URL} = $1;
}
else
{
$error .= '<li>Website Address is invalid. The URL must be in this form: <b>http://example.com</b></li>';
}

允许HTTP和HTTPS,但不会将任何内容保存到数据库

我想要的是让HTTPS和HTTP有效,并保存在数据库中。

REGEXP :: CONCOL :: URI :: HTTP的-scheme标志采用一个参数,该参数是匹配允许的方案的条件。它默认仅匹配http并忽略参数似乎意味着该方案根本不包括在比赛中。因此,要匹配http和https,您可以将其传递给https?的正则罚款:

m/$RE{URI}{HTTP}{-scheme => qr<https?>}{-keep}/

相关内容

最新更新