Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/utils/headerFooterHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copied from mashlib/src/global/metadata.ts
*/
import { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib'
import { authn, store } from 'solid-logic'
import { ns } from '..'

/* @ts-ignore no-console */
Expand All @@ -15,7 +16,16 @@ type ThrottleOptions = {
* @ignore exporting this only for the unit test
*/
export function getPod (): NamedNode {
// @@ TODO: This is given that mashlib runs on NSS - might need to change when we want it to run on other Pod servers
// Try to get pod from logged-in user's pim:storage
const user = authn.currentUser()
if (user) {
// Look up pim:storage from user's profile
const storages = store.each(user, ns.space('storage'), null, user.doc())
if (storages.length > 0) {
return storages[0] as NamedNode
}
}
Comment on lines +19 to +27
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new logic for retrieving the pod from the logged-in user's pim:storage lacks test coverage. This is a critical change that introduces different behavior for path-based pod servers versus subdomain-based pod servers. Consider adding unit tests to verify:

  1. When a user is logged in and has pim:storage in their profile, the function returns the storage value
  2. When a user is logged in but has no pim:storage, the function falls back to origin-based detection
  3. When no user is logged in, the function falls back to origin-based detection
  4. When multiple storages exist, the function returns the first one

This is especially important since the function is already exported for testing (as noted in the comment on line 16).

Copilot uses AI. Check for mistakes.
// Fallback to origin-based (subdomain pattern) for backwards compatibility
return sym(document.location.origin).site()
}
/**
Expand Down