sdc-build-wp 5.5.2 → 5.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/page-script.js +16 -17
- package/package.json +1 -1
package/lib/page-script.js
CHANGED
|
@@ -5,23 +5,22 @@ let socket = window.___browserSync___?.socket;
|
|
|
5
5
|
let checkedForPort = false;
|
|
6
6
|
|
|
7
7
|
function redirectAdminFromPort() {
|
|
8
|
-
if (!checkedForPort && window.location.port) {
|
|
9
|
-
const url = new URL(window.location.href);
|
|
10
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
11
|
-
if (urlParams.has('keepPort')) {
|
|
12
|
-
checkedForPort = true;
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
url.port = '';
|
|
16
|
-
socket.emit('sdc:redirectAdminFromPort', {
|
|
17
|
-
timestamp: Date.now(),
|
|
18
|
-
port: window.location.port,
|
|
19
|
-
from: window.location.href,
|
|
20
|
-
to: url.toString()
|
|
21
|
-
});
|
|
22
|
-
window.location.replace(url.toString());
|
|
23
|
-
}
|
|
24
8
|
checkedForPort = true;
|
|
9
|
+
if (!window.location.port) { return; }
|
|
10
|
+
const url = new URL(window.location.href);
|
|
11
|
+
const isAdmin = /^\/wp-admin(?:\/|$)/.test(url.pathname);
|
|
12
|
+
const urlParams = new URLSearchParams(url.search);
|
|
13
|
+
if (!isAdmin || urlParams.has('keepPort')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
url.port = '';
|
|
17
|
+
socket.emit('sdc:redirectAdminFromPort', {
|
|
18
|
+
timestamp: Date.now(),
|
|
19
|
+
port: window.location.port,
|
|
20
|
+
from: window.location.href,
|
|
21
|
+
to: url.toString()
|
|
22
|
+
});
|
|
23
|
+
window.location.replace(url.toString());
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
function getScriptsOnPage() {
|
|
@@ -36,7 +35,7 @@ function getScriptsOnPage() {
|
|
|
36
35
|
const scriptsOnPageInterval = setInterval(() => {
|
|
37
36
|
socket = window.___browserSync___?.socket;
|
|
38
37
|
if (socket) {
|
|
39
|
-
redirectAdminFromPort();
|
|
38
|
+
if (!checkedForPort) { redirectAdminFromPort(); }
|
|
40
39
|
getScriptsOnPage();
|
|
41
40
|
clearInterval(scriptsOnPageInterval);
|
|
42
41
|
}
|