mirror of
https://github.com/processwire/processwire.git
synced 2025-08-16 19:54:24 +02:00
Add $sanitizer->httpUrl() method to accompany existing url() method
This commit is contained in:
@@ -1477,7 +1477,7 @@ class Sanitizer extends Wire {
|
|||||||
* - `stripQuotes` (bool): Specify false to prevent quotes from being stripped (default=true).
|
* - `stripQuotes` (bool): Specify false to prevent quotes from being stripped (default=true).
|
||||||
* - `maxLength` (int): Maximum length in bytes allowed for URLs (default=4096).
|
* - `maxLength` (int): Maximum length in bytes allowed for URLs (default=4096).
|
||||||
* - `throw` (bool): Throw exceptions on invalid URLs (default=false).
|
* - `throw` (bool): Throw exceptions on invalid URLs (default=false).
|
||||||
* @return string Returns a valid URL or blank string if it can't be made valid.
|
* @return string Returns a valid URL or blank string if it can’t be made valid.
|
||||||
* @throws WireException on invalid URLs, only if `$options['throw']` is true.
|
* @throws WireException on invalid URLs, only if `$options['throw']` is true.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -1663,6 +1663,24 @@ class Sanitizer extends Wire {
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL with http or https scheme required
|
||||||
|
*
|
||||||
|
* #pw-group-strings
|
||||||
|
* #pw-group-validate
|
||||||
|
*
|
||||||
|
* @param string $value URL to validate
|
||||||
|
* @param array $options See the url() method for all options.
|
||||||
|
* @return string Returns valid URL or blank string if it cannot be made valid.
|
||||||
|
* @since 3.0.129
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function httpUrl($value, $options = array()) {
|
||||||
|
$options['requireScheme'] = true;
|
||||||
|
if(empty($options['allowSchemes'])) $options['allowSchemes'] = array('http', 'https');
|
||||||
|
return $this->url($value, $options);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of PHP's FILTER_VALIDATE_URL with IDN and underscore support (will convert to valid)
|
* Implementation of PHP's FILTER_VALIDATE_URL with IDN and underscore support (will convert to valid)
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user