Skip to content

Commit f33058b

Browse files
committed
remove extra if statement
1 parent 955507a commit f33058b

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

packages/qwik/src/optimizer/src/plugins/click-to-component.html

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
cursor: pointer;
1111
z-index: 999999;
1212
}
13+
1314
#qwik-inspector-info-popup {
1415
position: fixed;
1516
bottom: 10px;
@@ -28,13 +29,16 @@
2829
z-index: 999999;
2930
contain: layout;
3031
}
32+
3133
#qwik-inspector-info-popup p {
3234
margin: 0px;
3335
}
36+
3437
@-webkit-keyframes fadeOut {
3538
0% {
3639
opacity: 1;
3740
}
41+
3842
100% {
3943
opacity: 0;
4044
}
@@ -44,6 +48,7 @@
4448
0% {
4549
opacity: 1;
4650
}
51+
4752
100% {
4853
opacity: 0;
4954
visibility: hidden;
@@ -144,28 +149,24 @@
144149

145150
globalThis.qwikOpenInEditor = function (path) {
146151
const isWindows = navigator.platform.includes('Win');
147-
const isMac = navigator.platform.includes('Mac');
148152
const resolvedURL = new URL(path, isWindows ? origin : srcDir);
149-
const prefix = isWindows ? srcDir : '';
150-
if (isWindows || isMac) {
151-
let finalPath;
152-
const params = new URLSearchParams();
153-
const filePath =
154-
resolvedURL.protocol === 'file:' && resolvedURL.pathname.startsWith('/')
155-
? resolvedURL.pathname.slice(1)
156-
: resolvedURL.pathname;
157-
if (filePath.startsWith(prefix)) {
158-
finalPath = filePath;
159-
} else {
160-
const cleaned = filePath.replace(/^[/\\]?src[/\\]/, '');
161-
const sep = '\\';
162-
finalPath = prefix.endsWith(sep) ? prefix + cleaned : prefix + sep + cleaned;
163-
}
164-
params.set('file', finalPath);
165-
fetch('/__open-in-editor?' + params.toString());
153+
const prefix = isWindows ? srcDir : srcDir.replace('http://local.local', '');
154+
const params = new URLSearchParams();
155+
const filePath =
156+
resolvedURL.protocol === 'file:' && resolvedURL.pathname.startsWith('/')
157+
? resolvedURL.pathname.slice(1)
158+
: resolvedURL.pathname;
159+
let finalPath;
160+
if (filePath.startsWith(prefix)) {
161+
finalPath = filePath;
166162
} else {
167-
location.href = resolvedURL.href;
163+
// remove the extra src from filePath as prefix already contains it
164+
const cleaned = filePath.replace(/^[/\\]?src[/\\]/, '');
165+
const sep = isWindows ? '\\' : '/';
166+
finalPath = prefix.endsWith(sep) ? prefix + cleaned : prefix + sep + cleaned;
168167
}
168+
params.set('file', finalPath);
169+
fetch('/__open-in-editor?' + params.toString());
169170
};
170171
document.addEventListener(
171172
'contextmenu',

0 commit comments

Comments
 (0)