Skip to content

Commit f654ea0

Browse files
committed
Simplify remoteExtPath regex
1 parent c290740 commit f654ea0

File tree

6 files changed

+18
-48
lines changed

6 files changed

+18
-48
lines changed

src/Deserializers/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

src/Serializers/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

src/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

tests/Deserializers/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

tests/Serializers/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

tests/resources.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,12 @@
77
*/
88
return call_user_func( function() {
99

10-
preg_match(
11-
'+^(.*?)' . preg_quote( DIRECTORY_SEPARATOR ) . '(vendor|extensions)' .
12-
preg_quote( DIRECTORY_SEPARATOR ) . '(.*)$+',
13-
__DIR__,
14-
$remoteExtPathParts
15-
);
10+
preg_match( '+' . preg_quote( DIRECTORY_SEPARATOR ) . '(?:vendor|extensions)'
11+
. preg_quote( DIRECTORY_SEPARATOR ) . '.*+', __DIR__, $remoteExtPath );
1612

1713
$moduleTemplate = array(
1814
'localBasePath' => __DIR__,
19-
'remoteExtPath' => '../' . $remoteExtPathParts[2]
20-
. DIRECTORY_SEPARATOR . $remoteExtPathParts[3],
15+
'remoteExtPath' => '..' . $remoteExtPath[0],
2116
);
2217

2318
$modules = array(

0 commit comments

Comments
 (0)