Indexes for performance improvements, improved FTN regex
This commit is contained in:
@@ -32,6 +32,9 @@ class Address extends Model
|
||||
|
||||
protected $with = ['zone'];
|
||||
|
||||
// http://ftsc.org/docs/frl-1028.002
|
||||
public const ftn_regex = '([0-9]+):([0-9]+)/([0-9]+)(\.([0-9]+))?(@([a-z0-9\-_~]{0,8}))?';
|
||||
|
||||
public const NODE_ZC = 1<<0; // Zone
|
||||
public const NODE_RC = 1<<1; // Region
|
||||
public const NODE_NC = 1<<2; // Host
|
||||
@@ -513,6 +516,7 @@ class Address extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Parse a string and split it out as an FTN array
|
||||
*
|
||||
* @param string $ftn
|
||||
@@ -521,8 +525,7 @@ class Address extends Model
|
||||
*/
|
||||
public static function parseFTN(string $ftn): array
|
||||
{
|
||||
// http://ftsc.org/docs/frl-1028.002
|
||||
if (! preg_match('#^([0-9]+):([0-9]+)/([0-9]+)(.([0-9]+))?(@([a-z0-9\-_~]{0,8}))?$#',strtolower($ftn),$matches))
|
||||
if (! preg_match(sprintf('#^%s$#',self::ftn_regex),strtolower($ftn),$matches))
|
||||
throw new Exception('Invalid FTN: '.$ftn);
|
||||
|
||||
// Check our numbers are correct.
|
||||
|
Reference in New Issue
Block a user