-
Notifications
You must be signed in to change notification settings - Fork 12
Allow opening linked filedef in the stack #4013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d4be9f0
dc12037
0b9d449
c88c5b3
2e51a09
918c240
c0f0c60
3c9dcbd
17cb08a
9651f9d
cb32ae9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import type { StoreReadType } from '@cardstack/runtime-common'; | ||
| import { hasExtension } from '@cardstack/runtime-common/url'; | ||
|
|
||
| export function isFileMetaId(id: string | null | undefined): boolean { | ||
| if (!id) { | ||
| return false; | ||
| } | ||
| return hasExtension(id) && !id.endsWith('.json'); | ||
| } | ||
|
|
||
| export function inferStoreReadType( | ||
| id: string | null | undefined, | ||
| ): StoreReadType { | ||
| return isFileMetaId(id) ? 'file-meta' : 'card'; | ||
| } | ||
|
Comment on lines
+4
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an AI anti-pattern that I have had to fight . We should be using more explicit type specification, not inferring stuff from URLs
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note from our call:
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
cardOrURLis a URL string that points to a file (has extension, not .json), but the file-meta instance is not yet loaded in the store, this method will return 'card' instead of 'file-meta'. This could cause the wrong type to be used when opening a file via direct navigation. Consider usinginferStoreReadTypeas a fallback when no instance is found in the store to correctly detect file URLs based on their extension pattern.