uri
uri copied to clipboard
Unknown modifier error on the regex for uris that have an authority part
Sorry to hassle you again folks, but I'm running the tests on the project and am coming up against an issue with functions.php line 360.
Numerous tests are failing with the same issue, but I'm focusing on the "http://example.org:8080/" test.
I've pasted the relevant code into http://sandbox.onlinephpfunctions.com/ so that I can test it against different PHP versions. The code is:
<?php
$uri = '//example.org:8080/';
$regex = '
%^
//
(?: (?<user> [^:@]+) (: (?<pass> [^@]+)) @)?
(?<host> ( [^:/]* | \[ [^\]]+ \] ))
(?: : (?<port> [0-9]+))?
(?<path> / .*)?
$%x
';
var_dump(preg_match($regex, $uri, $matches));
var_dump($matches);
The error I'm getting is:
<b>Warning</b>: preg_match(): Unknown modifier '
' in <b>[...][...]</b> on line <b>12</b><br />
bool(false)
NULL
Any advice would be appreciated. Thank you.
Looks like this is another duplicate of https://github.com/sabre-io/uri/pull/25 Peter's fix (removing the newlines from the beginning and end of the regex) seems to have fixed it. Once that is merged this can be closed.