From 5b3a511df7d2537a61c69dcd3e16982d522bd333 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Fri, 1 May 2026 15:51:46 -0500 Subject: [PATCH 1/4] Add RealmService.contains for cross-form membership checks Substring-prefix checks like `card.id.startsWith(realm)` only work when both sides are in the same form (URL vs registered prefix). After RRI migration, IDs may be prefix-form while realm URLs are URL-form (or vice versa), silently breaking those checks. `contains` resolves both sides to URL form via `cardIdToURL` before delegating to `RealmPaths.inRealm`, so cross-form comparisons work as long as the prefix is registered. Sweeps the two known callers in `search.ts` and `workspace.gts`. --- .../workspace-chooser/workspace.gts | 2 +- packages/host/app/resources/search.ts | 6 +++++- packages/host/app/services/realm.ts | 21 +++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts index f20e982ebe1..3a99cdbf768 100644 --- a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts +++ b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts @@ -991,7 +991,7 @@ export default class Workspace extends Component { this.operatorModeStateService.realmURL === this.args.realmURL || this.operatorModeStateService .getOpenCardIds() - .some((cardId) => cardId.startsWith(this.args.realmURL)) || + .some((cardId) => this.realm.contains(this.args.realmURL, cardId)) || this.operatorModeStateService.codePathString?.startsWith( this.args.realmURL, ); diff --git a/packages/host/app/resources/search.ts b/packages/host/app/resources/search.ts index 8cc46b6f20d..0a9475ef828 100644 --- a/packages/host/app/resources/search.ts +++ b/packages/host/app/resources/search.ts @@ -32,6 +32,7 @@ import type { CardDef } from 'https://cardstack.com/base/card-api'; import type { FileDef } from 'https://cardstack.com/base/file-api'; import type { RealmEventContent } from 'https://cardstack.com/base/matrix-event'; +import type RealmService from '../services/realm'; import type RealmServerService from '../services/realm-server'; import type StoreService from '../services/store'; @@ -67,6 +68,7 @@ export interface Args { export class SearchResource< T extends CardDef | FileDef = CardDef, > extends Resource> { + @service declare private realm: RealmService; @service declare private realmServer: RealmServerService; @service declare private store: StoreService; #storeServiceOverride: StoreService | undefined; @@ -299,7 +301,9 @@ export class SearchResource< get instancesByRealm() { return this.realmsToSearch .map((realm) => { - let cards = this.instances.filter((card) => card.id.startsWith(realm)); + let cards = this.instances.filter((card) => + this.realm.contains(realm, card.id), + ); return { realm, cards }; }) .filter((r) => r.cards.length > 0); diff --git a/packages/host/app/services/realm.ts b/packages/host/app/services/realm.ts index f37d27de9b1..bc276cd3aea 100644 --- a/packages/host/app/services/realm.ts +++ b/packages/host/app/services/realm.ts @@ -945,6 +945,27 @@ export default class RealmService extends Service { return undefined; } + // Cross-form realm-membership check. + // + // Both `realm` and `resource` may be in URL form (`http://...`) or + // registered-prefix form (`@cardstack/...`). Internally both sides are + // resolved to URL form via `cardIdToURL` before comparison, so a URL-form + // realm correctly matches a prefix-form resource (and vice versa) as long + // as the prefix is registered in `prefixMappings`. Returns `false` if + // either side fails to resolve. + contains(realm: string | URL, resource: string | URL): boolean { + let realmHref: string; + let resourceHref: string; + try { + realmHref = realm instanceof URL ? realm.href : cardIdToURL(realm).href; + resourceHref = + resource instanceof URL ? resource.href : cardIdToURL(resource).href; + } catch { + return false; + } + return new RealmPaths(new URL(realmHref)).inRealm(rri(resourceHref)); + } + realmForSessionRoomId(sessionRoomId: string) { return Array.from(this.realms.values()).find( (r) => r.claims?.sessionRoom === sessionRoomId, From 9a39a4acedf071fc4190dbe145c1c2d57280379b Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Mon, 4 May 2026 09:09:31 -0700 Subject: [PATCH 2/4] Fix language in function comments Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- packages/host/app/services/realm.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/host/app/services/realm.ts b/packages/host/app/services/realm.ts index bc276cd3aea..01ac0d702c3 100644 --- a/packages/host/app/services/realm.ts +++ b/packages/host/app/services/realm.ts @@ -947,12 +947,14 @@ export default class RealmService extends Service { // Cross-form realm-membership check. // - // Both `realm` and `resource` may be in URL form (`http://...`) or - // registered-prefix form (`@cardstack/...`). Internally both sides are - // resolved to URL form via `cardIdToURL` before comparison, so a URL-form - // realm correctly matches a prefix-form resource (and vice versa) as long - // as the prefix is registered in `prefixMappings`. Returns `false` if - // either side fails to resolve. + // `realm` may be in URL form (`http://...`) or as a registered realm-root + // identifier/prefix (for example `@cardstack/base/`, including the trailing + // slash). `resource` may be in URL form or registered-prefix form. + // Internally both sides are resolved to URL form via `cardIdToURL` before + // comparison, so a URL-form realm correctly matches a prefix-form resource + // (and vice versa) as long as the prefix is registered in `prefixMappings`. + // Returns `false` if either side fails to resolve, including when a + // non-URL-like string does not match a registered prefix exactly. contains(realm: string | URL, resource: string | URL): boolean { let realmHref: string; let resourceHref: string; From 50bf89b134af1c05fb7cb8901f62c7da0974efa4 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Tue, 5 May 2026 19:13:09 -0500 Subject: [PATCH 3/4] Tighten contains signature to branded RealmIdentifier/RRI Per review: use the existing branded types in the helper signature so intent is documented through the type system. Callers cast their unbranded strings via `ri()` / `rri()` for now; tightening the source types of `availableRealmURLs`, `Workspace.args.realmURL`, and `CardDef.id` is tracked separately. --- .../operator-mode/workspace-chooser/workspace.gts | 6 +++++- packages/host/app/resources/search.ts | 4 +++- packages/host/app/services/realm.ts | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts index 3a99cdbf768..af27e225b28 100644 --- a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts +++ b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts @@ -32,6 +32,8 @@ import { import { hasExecutableExtension, + ri, + rri, SupportedMimeType, } from '@cardstack/runtime-common'; @@ -991,7 +993,9 @@ export default class Workspace extends Component { this.operatorModeStateService.realmURL === this.args.realmURL || this.operatorModeStateService .getOpenCardIds() - .some((cardId) => this.realm.contains(this.args.realmURL, cardId)) || + .some((cardId) => + this.realm.contains(ri(this.args.realmURL), rri(cardId)), + ) || this.operatorModeStateService.codePathString?.startsWith( this.args.realmURL, ); diff --git a/packages/host/app/resources/search.ts b/packages/host/app/resources/search.ts index 0a9475ef828..53eddb6b235 100644 --- a/packages/host/app/resources/search.ts +++ b/packages/host/app/resources/search.ts @@ -24,6 +24,8 @@ import { normalizeQueryForSignature, buildQueryParamValue, parseSearchURL, + ri, + rri, runtimeDependencyContextWithSource, } from '@cardstack/runtime-common'; import type { Query } from '@cardstack/runtime-common/query'; @@ -302,7 +304,7 @@ export class SearchResource< return this.realmsToSearch .map((realm) => { let cards = this.instances.filter((card) => - this.realm.contains(realm, card.id), + this.realm.contains(ri(realm), rri(card.id)), ); return { realm, cards }; }) diff --git a/packages/host/app/services/realm.ts b/packages/host/app/services/realm.ts index 20c1fe8d14f..78fb4f250cb 100644 --- a/packages/host/app/services/realm.ts +++ b/packages/host/app/services/realm.ts @@ -961,7 +961,10 @@ export default class RealmService extends Service { // (and vice versa) as long as the prefix is registered in `prefixMappings`. // Returns `false` if either side fails to resolve, including when a // non-URL-like string does not match a registered prefix exactly. - contains(realm: string | URL, resource: string | URL): boolean { + contains( + realm: RealmIdentifier | URL, + resource: RealmResourceIdentifier | URL, + ): boolean { let realmHref: string; let resourceHref: string; try { From bd942a3a4972ea0a84fefca7564dc86554e22f94 Mon Sep 17 00:00:00 2001 From: Buck Doyle Date: Wed, 6 May 2026 07:37:40 -0500 Subject: [PATCH 4/4] Widen RealmPaths.inRealm to handle cross-form input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per review: extend `inRealm` to accept `RealmResourceIdentifier | URL` and normalize both sides to URL form internally when the same-form `startsWith` fails. The recurring `inRealm(rri(.href))` and `inRealm(rri(cardIdToURL(...).href))` idioms collapse to passing the URL or branded RRI directly. This also makes `RealmService.contains` redundant — drop it; callers construct `new RealmPaths(realm).inRealm(resource)` directly (and can hoist the `RealmPaths` out of inner loops). Sweeps 17 call sites across runtime-common, host, and realm-server. --- .../workspace-chooser/workspace.gts | 6 ++-- packages/host/app/resources/search.ts | 6 ++-- .../services/operator-mode-state-service.ts | 2 +- packages/host/app/services/realm.ts | 26 --------------- .../host/app/services/recent-files-service.ts | 4 +-- packages/realm-server/server.ts | 5 ++- packages/runtime-common/catalog.ts | 8 ++--- packages/runtime-common/index-writer.ts | 4 +-- packages/runtime-common/paths.ts | 33 ++++++++++++++++--- packages/runtime-common/realm-index-card.ts | 4 +-- .../realm-index-query-engine.ts | 3 +- packages/runtime-common/realm.ts | 4 +-- packages/runtime-common/url.ts | 6 ++-- packages/runtime-common/virtual-network.ts | 5 ++- 14 files changed, 55 insertions(+), 61 deletions(-) diff --git a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts index af27e225b28..1fe07e499c7 100644 --- a/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts +++ b/packages/host/app/components/operator-mode/workspace-chooser/workspace.gts @@ -32,6 +32,7 @@ import { import { hasExecutableExtension, + RealmPaths, ri, rri, SupportedMimeType, @@ -989,13 +990,12 @@ export default class Workspace extends Component { this.deleteError = undefined; try { + let realmPath = new RealmPaths(ri(this.args.realmURL)); let isActiveWorkspace = this.operatorModeStateService.realmURL === this.args.realmURL || this.operatorModeStateService .getOpenCardIds() - .some((cardId) => - this.realm.contains(ri(this.args.realmURL), rri(cardId)), - ) || + .some((cardId) => realmPath.inRealm(rri(cardId))) || this.operatorModeStateService.codePathString?.startsWith( this.args.realmURL, ); diff --git a/packages/host/app/resources/search.ts b/packages/host/app/resources/search.ts index 53eddb6b235..42990168d01 100644 --- a/packages/host/app/resources/search.ts +++ b/packages/host/app/resources/search.ts @@ -26,6 +26,7 @@ import { parseSearchURL, ri, rri, + RealmPaths, runtimeDependencyContextWithSource, } from '@cardstack/runtime-common'; import type { Query } from '@cardstack/runtime-common/query'; @@ -34,7 +35,6 @@ import type { CardDef } from 'https://cardstack.com/base/card-api'; import type { FileDef } from 'https://cardstack.com/base/file-api'; import type { RealmEventContent } from 'https://cardstack.com/base/matrix-event'; -import type RealmService from '../services/realm'; import type RealmServerService from '../services/realm-server'; import type StoreService from '../services/store'; @@ -70,7 +70,6 @@ export interface Args { export class SearchResource< T extends CardDef | FileDef = CardDef, > extends Resource> { - @service declare private realm: RealmService; @service declare private realmServer: RealmServerService; @service declare private store: StoreService; #storeServiceOverride: StoreService | undefined; @@ -303,8 +302,9 @@ export class SearchResource< get instancesByRealm() { return this.realmsToSearch .map((realm) => { + let realmPath = new RealmPaths(ri(realm)); let cards = this.instances.filter((card) => - this.realm.contains(ri(realm), rri(card.id)), + realmPath.inRealm(rri(card.id)), ); return { realm, cards }; }) diff --git a/packages/host/app/services/operator-mode-state-service.ts b/packages/host/app/services/operator-mode-state-service.ts index 3ecf942e489..8cd59f9d63e 100644 --- a/packages/host/app/services/operator-mode-state-service.ts +++ b/packages/host/app/services/operator-mode-state-service.ts @@ -725,7 +725,7 @@ export default class OperatorModeStateService extends Service { if (this._state.codePath && this.realmURL) { let realmPath = new RealmPaths(new URL(this.realmURL)); - if (realmPath.inRealm(rri(this._state.codePath.href))) { + if (realmPath.inRealm(this._state.codePath)) { try { return realmPath.local(this._state.codePath!); } catch (err: any) { diff --git a/packages/host/app/services/realm.ts b/packages/host/app/services/realm.ts index 78fb4f250cb..1ad880820c2 100644 --- a/packages/host/app/services/realm.ts +++ b/packages/host/app/services/realm.ts @@ -951,32 +951,6 @@ export default class RealmService extends Service { return undefined; } - // Cross-form realm-membership check. - // - // `realm` may be in URL form (`http://...`) or as a registered realm-root - // identifier/prefix (for example `@cardstack/base/`, including the trailing - // slash). `resource` may be in URL form or registered-prefix form. - // Internally both sides are resolved to URL form via `cardIdToURL` before - // comparison, so a URL-form realm correctly matches a prefix-form resource - // (and vice versa) as long as the prefix is registered in `prefixMappings`. - // Returns `false` if either side fails to resolve, including when a - // non-URL-like string does not match a registered prefix exactly. - contains( - realm: RealmIdentifier | URL, - resource: RealmResourceIdentifier | URL, - ): boolean { - let realmHref: string; - let resourceHref: string; - try { - realmHref = realm instanceof URL ? realm.href : cardIdToURL(realm).href; - resourceHref = - resource instanceof URL ? resource.href : cardIdToURL(resource).href; - } catch { - return false; - } - return new RealmPaths(new URL(realmHref)).inRealm(rri(resourceHref)); - } - realmForSessionRoomId(sessionRoomId: string) { return Array.from(this.realms.values()).find( (r) => r.claims?.sessionRoom === sessionRoomId, diff --git a/packages/host/app/services/recent-files-service.ts b/packages/host/app/services/recent-files-service.ts index 2dbfa8b1dc1..791437ffe43 100644 --- a/packages/host/app/services/recent-files-service.ts +++ b/packages/host/app/services/recent-files-service.ts @@ -7,7 +7,7 @@ import { tracked } from '@glimmer/tracking'; import window from 'ember-window-mock'; import { TrackedArray } from 'tracked-built-ins'; -import { RealmPaths, rri } from '@cardstack/runtime-common'; +import { RealmPaths } from '@cardstack/runtime-common'; import type { LocalPath } from '@cardstack/runtime-common/paths'; import { RecentFiles } from '../utils/local-storage-keys'; @@ -90,7 +90,7 @@ export default class RecentFilesService extends Service { let realmPaths = new RealmPaths(new URL(realmURL)); let url = new URL(urlString); - if (realmPaths.inRealm(rri(url.href))) { + if (realmPaths.inRealm(url)) { this.addRecentFile(realmPaths.local(url)); } } diff --git a/packages/realm-server/server.ts b/packages/realm-server/server.ts index ef39401d644..64c89219a2a 100644 --- a/packages/realm-server/server.ts +++ b/packages/realm-server/server.ts @@ -21,7 +21,6 @@ import { DEFAULT_CARD_SIZE_LIMIT_BYTES, DEFAULT_FILE_SIZE_LIMIT_BYTES, RealmPaths, - rri, fetchSessionRoom, hasExtension, executableExtensions, @@ -621,7 +620,7 @@ export class RealmServer { let legacy = this.realms.find((candidate) => { let realmURL = new URL(candidate.url); realmURL.protocol = requestURL.protocol; - return new RealmPaths(realmURL).inRealm(rri(requestURL.href)); + return new RealmPaths(realmURL).inRealm(requestURL); }); if (legacy) { return legacy; @@ -629,7 +628,7 @@ export class RealmServer { for (const url of this.reconciler.knownByUrl.keys()) { let realmURL = new URL(url); realmURL.protocol = requestURL.protocol; - if (new RealmPaths(realmURL).inRealm(rri(requestURL.href))) { + if (new RealmPaths(realmURL).inRealm(requestURL)) { return await this.reconciler.lookupOrMount(url); } } diff --git a/packages/runtime-common/catalog.ts b/packages/runtime-common/catalog.ts index 441cc9be239..1a77d122255 100644 --- a/packages/runtime-common/catalog.ts +++ b/packages/runtime-common/catalog.ts @@ -195,7 +195,7 @@ function resolveTargetCodeRef( codeRef: ResolvedCodeRef, resolver: ListingPathResolver, ): ResolvedCodeRef { - if (baseRealmPath.inRealm(rri(cardIdToURL(codeRef.module).href))) { + if (baseRealmPath.inRealm(codeRef.module)) { return codeRef; } else { let targetModule = resolver.target(cardIdToURL(codeRef.module).href); @@ -220,7 +220,7 @@ export function planModuleInstall( }; }); let modulesCopy = codeRefs.flatMap((sourceCodeRef: ResolvedCodeRef) => { - if (baseRealmPath.inRealm(rri(cardIdToURL(sourceCodeRef.module).href))) { + if (baseRealmPath.inRealm(sourceCodeRef.module)) { return []; } let targetCodeRef = resolveTargetCodeRef(sourceCodeRef, resolver); @@ -242,10 +242,10 @@ export function planInstanceInstall( for (let instance of instances) { let sourceCodeRef = resolveAdoptedCodeRef(instance); let lid = resolver.local(cardIdToURL(instance.id).href); - if (baseRealmPath.inRealm(rri(cardIdToURL(instance.id).href))) { + if (baseRealmPath.inRealm(rri(instance.id))) { throw new Error('Cannot install instance from base realm'); } - if (!baseRealmPath.inRealm(rri(cardIdToURL(sourceCodeRef.module).href))) { + if (!baseRealmPath.inRealm(sourceCodeRef.module)) { let targetCodeRef = resolveTargetCodeRef(sourceCodeRef, resolver); modulesCopy.push({ sourceCodeRef, diff --git a/packages/runtime-common/index-writer.ts b/packages/runtime-common/index-writer.ts index f2d33026dc0..a7d0741f447 100644 --- a/packages/runtime-common/index-writer.ts +++ b/packages/runtime-common/index-writer.ts @@ -309,7 +309,7 @@ export class Batch { } async updateEntry(url: URL, entry: SearchIndexEntry): Promise { - if (!new RealmPaths(this.realmURL).inRealm(rri(url.href))) { + if (!new RealmPaths(this.realmURL).inRealm(url)) { // TODO this is a workaround for CS-6886. after we have solved that issue we can // drop this band-aid return; @@ -1115,7 +1115,7 @@ export class Batch { private copiedRealmURL(fromRealm: URL, file: URL): URL { let source = new RealmPaths(fromRealm); let dest = new RealmPaths(this.realmURL); - if (!source.inRealm(rri(file.href))) { + if (!source.inRealm(file)) { return file; } let local = source.local(file); diff --git a/packages/runtime-common/paths.ts b/packages/runtime-common/paths.ts index 46af44d14fd..e99de731765 100644 --- a/packages/runtime-common/paths.ts +++ b/packages/runtime-common/paths.ts @@ -1,4 +1,4 @@ -import { rri } from './card-reference-resolver'; +import { cardIdToURL } from './card-reference-resolver'; import type { RealmIdentifier, RealmResourceIdentifier, @@ -42,7 +42,7 @@ export class RealmPaths { ): LocalPath { if (input instanceof URL) { this.assertURLBased('local'); - if (!this.inRealm(rri(input.href))) { + if (!this.inRealm(input)) { let error = new Error( `realm ${this.url} does not contain ${input.href}`, ); @@ -88,17 +88,40 @@ export class RealmPaths { return new URL(local + '/', this.url); } - inRealm(input: RealmResourceIdentifier): boolean { + inRealm(input: RealmResourceIdentifier | URL): boolean { + let inputStr = input instanceof URL ? input.href : input; let decoded: string; try { - decoded = decodeURI(input); + decoded = decodeURI(inputStr); } catch { return false; } - return ( + // Same-form fast path: both sides URL or both prefix. + if ( decoded.startsWith(this.url) || // realm root with missing trailing slash, optionally with query string decoded.split('?')[0] === this.url.replace(/\/$/, '') + ) { + return true; + } + // Cross-form: normalize both sides to URL form and re-check. + let realmURL: string; + let inputURL: string; + try { + realmURL = cardIdToURL(this.url).href; + inputURL = cardIdToURL(inputStr).href; + } catch { + return false; + } + let decodedURL: string; + try { + decodedURL = decodeURI(inputURL); + } catch { + return false; + } + return ( + decodedURL.startsWith(realmURL) || + decodedURL.split('?')[0] === realmURL.replace(/\/$/, '') ); } diff --git a/packages/runtime-common/realm-index-card.ts b/packages/runtime-common/realm-index-card.ts index 3b4ab64bb5a..8e9d964e3e9 100644 --- a/packages/runtime-common/realm-index-card.ts +++ b/packages/runtime-common/realm-index-card.ts @@ -1,7 +1,7 @@ import type { CardDef } from 'https://cardstack.com/base/card-api'; import { realmURL } from './constants'; -import { cardIdToURL, rri } from './card-reference-resolver'; +import { cardIdToURL } from './card-reference-resolver'; import { RealmPaths } from './paths'; export function isRealmIndexCardId( @@ -17,7 +17,7 @@ export function isRealmIndexCardId( ); let cardURL = cardIdToURL(cardId); return ( - realmPaths.inRealm(rri(cardURL.href)) && + realmPaths.inRealm(cardURL) && realmPaths.local(cardURL) === 'index' ); } catch { diff --git a/packages/runtime-common/realm-index-query-engine.ts b/packages/runtime-common/realm-index-query-engine.ts index e37d7eaf16d..18450637e87 100644 --- a/packages/runtime-common/realm-index-query-engine.ts +++ b/packages/runtime-common/realm-index-query-engine.ts @@ -11,7 +11,6 @@ import { resolveCardReference, isRegisteredPrefix, cardIdToURL, - rri, unresolveCardReference, IndexQueryEngine, codeRefWithAbsoluteIdentifier, @@ -949,7 +948,7 @@ export class RealmIndexQueryEngine { ), ); let linkResource: CardResource | FileMetaResource | undefined; - if (realmPath.inRealm(rri(linkURL.href))) { + if (realmPath.inRealm(linkURL)) { if (expectsCard || (!relationshipType && !expectsFileMeta)) { let maybeResult = await this.#indexQueryEngine.getInstance( linkURL, diff --git a/packages/runtime-common/realm.ts b/packages/runtime-common/realm.ts index ec3c5aea1ab..780becd574d 100644 --- a/packages/runtime-common/realm.ts +++ b/packages/runtime-common/realm.ts @@ -1047,7 +1047,7 @@ export class Realm { requestContext, }); } - if (!this.paths.inRealm(rri(parsedURL.href))) { + if (!this.paths.inRealm(parsedURL)) { return badRequest({ message: `URL is not in realm: ${parsedURL.href}`, requestContext, @@ -5389,7 +5389,7 @@ function isGloballyPublicDependency(resourceUrl: string): boolean { ) { return true; } - return baseRealm.inRealm(rri(parsed.href)); + return baseRealm.inRealm(parsed); } function lastModifiedHeader( diff --git a/packages/runtime-common/url.ts b/packages/runtime-common/url.ts index c4cbea70e56..43945af5b91 100644 --- a/packages/runtime-common/url.ts +++ b/packages/runtime-common/url.ts @@ -1,7 +1,7 @@ import type { LooseCardResource, FileMetaResource } from './index'; import { relationshipEntries } from './relationship-utils'; import { RealmPaths } from './paths'; -import { rri, unresolveCardReference } from './card-reference-resolver'; +import { unresolveCardReference } from './card-reference-resolver'; export function maybeURL( possibleURL: string, @@ -29,8 +29,8 @@ export function relativeURL( let realmPath = new RealmPaths(realmURL); // don't return a relative URL for URL that is outside of our realm if ( - realmPath.inRealm(rri(relativeTo.href)) && - !realmPath.inRealm(rri(url.href)) + realmPath.inRealm(relativeTo) && + !realmPath.inRealm(url) ) { return undefined; } diff --git a/packages/runtime-common/virtual-network.ts b/packages/runtime-common/virtual-network.ts index a48cffa1366..5955448eda4 100644 --- a/packages/runtime-common/virtual-network.ts +++ b/packages/runtime-common/virtual-network.ts @@ -2,7 +2,6 @@ import { RealmPaths, ensureTrailingSlash } from './paths'; import { baseRealm } from './index'; import { registerCardReferencePrefix, - rri, type RealmIdentifier, } from './card-reference-resolver'; import type { ModuleDescriptor } from './package-shim-handler'; @@ -109,7 +108,7 @@ export class VirtualNetwork { let sourcePath = new RealmPaths( new URL(direction === 'virtual-to-real' ? virtual : real), ); - if (sourcePath.inRealm(rri(absoluteURL.href))) { + if (sourcePath.inRealm(absoluteURL)) { let toPath = new RealmPaths( new URL(direction === 'virtual-to-real' ? real : virtual), ); @@ -286,7 +285,7 @@ function shouldRetryFetch(url: URL) { return false; } - if (baseRealm.inRealm(rri(url.href))) { + if (baseRealm.inRealm(url)) { return true; }