Skip to content

Commit 067ad2c

Browse files
Formatting: Enhance regex to remove protocol from URLs
1 parent 6b57942 commit 067ad2c

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/wp-admin/includes/network.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function get_clean_basedomain() {
8989
if ( $existing_domain ) {
9090
return $existing_domain;
9191
}
92-
$domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
92+
$domain = preg_replace( '|^https?://|', '', get_option( 'siteurl' ) );
9393
$slash = strpos( $domain, '/' );
9494
if ( $slash ) {
9595
$domain = substr( $domain, 0, $slash );

src/wp-includes/default-constants.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,14 +301,14 @@ function wp_cookie_constants() {
301301
* @since 1.2.0
302302
*/
303303
if ( ! defined( 'COOKIEPATH' ) ) {
304-
define( 'COOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'home' ) . '/' ) );
304+
define( 'COOKIEPATH', preg_replace( '|^https?://[^/]+|i', '', get_option( 'home' ) . '/' ) );
305305
}
306306

307307
/**
308308
* @since 1.5.0
309309
*/
310310
if ( ! defined( 'SITECOOKIEPATH' ) ) {
311-
define( 'SITECOOKIEPATH', preg_replace( '|https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) );
311+
define( 'SITECOOKIEPATH', preg_replace( '|^https?://[^/]+|i', '', get_option( 'siteurl' ) . '/' ) );
312312
}
313313

314314
/**
@@ -322,7 +322,7 @@ function wp_cookie_constants() {
322322
* @since 2.6.0
323323
*/
324324
if ( ! defined( 'PLUGINS_COOKIE_PATH' ) ) {
325-
define( 'PLUGINS_COOKIE_PATH', preg_replace( '|https?://[^/]+|i', '', WP_PLUGIN_URL ) );
325+
define( 'PLUGINS_COOKIE_PATH', preg_replace( '|^https?://[^/]+|i', '', WP_PLUGIN_URL ) );
326326
}
327327

328328
/**

0 commit comments

Comments
 (0)