fix: Windows-only: attempt to avoid Windows Defender blocking
Massimo Melina committed
Dec 28, 2025 at 12:08 UTC
125f2aee9d47d9a91d56495be7bf390ec9eb7d4f
1 file changed
+4
-3
src/api.vfs.ts
+4
-3
@@ -235,7 +235,8 @@ export default {
235
236
async windows_integration({ parent }) {
237
const status = await getServerStatus(true)
238
- const h = status.http.listening ? status.http : status.https // prefer http on localhost
238
+ const useHttp = status.http.listening
239
+ const h = useHttp ? status.http : status.https // prefer http on localhost
240
const url = h.srv!.name + '://localhost:' + h.port
241
for (const k of ['*', 'Directory']) {
242
await reg('add', WINDOWS_REG_KEY.replace('*', k), '/ve', '/f', '/d', 'Add to HFS (new)')
@@ -245,8 +246,8 @@ export default {
246
$wsh = New-Object -ComObject Wscript.Shell;
247
$j = @{parent=@'\n${parent}\n'@; source=@'\n%1\n'@} | ConvertTo-Json -Compress
248
$j = [System.Text.Encoding]::UTF8.GetBytes($j);
248
- [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
249
- try {
249
+ ${useHttp ? '' : '[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}'}
250
+ try {
251
$res = Invoke-WebRequest -Uri '${url}/~/api/add_vfs' -UseBasicParsing -Method POST -Headers @{ 'x-hfs-anti-csrf' = '1' } -ContentType 'application/json' -TimeoutSec 2 -Body $j;
252
$json = $res.Content | ConvertFrom-Json; $link = $json.link; $link | Set-Clipboard;
253
$wsh.Popup('The link is ready to be pasted');