Skip to content

Commit d37684a

Browse files
authored
fix: add trusted domain only if not explicitly set (#960)
1 parent 41521df commit d37684a

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

.changeset/warm-pots-share.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"biome": patch
3+
---
4+
5+
Trust biome domain only if not set

src/extension.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -373,26 +373,38 @@ export default class Extension {
373373
* users to load Biome JSON schemas without having to manually add the domain
374374
* to their trusted domains list.
375375
*
376-
* The extension will only attempt to trust the biomejs.dev domain once, and
377-
* will store a flag in the global state to avoid attempting to trust the
378-
* domain multiple times. If the user untrusts the domain manually, we will
379-
* not attempt to trust it again, and the user will have to manually re-trust
380-
* the domain to load Biome JSON schemas again.
376+
* The extension only writes this setting when the domain is missing. If the
377+
* user has already configured an explicit value for the domain (including
378+
* `false`), we won't overwrite it and will mark this check as completed.
379+
*
380+
* We also store a flag in global state to avoid attempting this operation
381+
* multiple times. If the user removes or changes the domain manually later,
382+
* we won't attempt to restore it automatically.
381383
*/
382384
private async trustBiomeDomain(): Promise<void> {
383385
// If we've already attempted to trust the domain, don't do it again
384386
if (this.context.globalState.get("alreadyTrustedBiomeDomain")) {
385387
return;
386388
}
387389

390+
const biomeDomain = "https://biomejs.dev";
391+
388392
// Get the current list of trusted domains from the configuration
389393
const currentlyTrustedDomains = workspace
390394
.getConfiguration("json.schemaDownload")
391395
.get<Record<string, boolean>>("trustedDomains", {});
392396

397+
const hasExplicitBiomeDomainPreference =
398+
biomeDomain in currentlyTrustedDomains;
399+
400+
if (hasExplicitBiomeDomainPreference) {
401+
await this.context.globalState.update("alreadyTrustedBiomeDomain", true);
402+
return;
403+
}
404+
393405
const newlyTrustedDomains = {
394406
...currentlyTrustedDomains,
395-
"https://biomejs.dev": true,
407+
[biomeDomain]: true,
396408
};
397409

398410
// Update the trusted domains in the configuration

0 commit comments

Comments
 (0)