-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1685 from appwrite/fix-realtime
Fix realtime on multi-region for backups
- Loading branch information
Showing
3 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,30 @@ | ||
import { page } from '$app/stores'; | ||
import { get } from 'svelte/store'; | ||
|
||
/** | ||
* Returns the current project ID. | ||
* | ||
* The function first checks for a `project` parameter in the Svelte `$page` store. | ||
* If not found, it extracts the project ID from the pathname. | ||
* | ||
* Supports: | ||
* - Legacy structure: `/project-{projectID}/` | ||
* - Multi-region structure: `/project-{region}-{projectID}/` | ||
* | ||
* Example: | ||
* - `/project-console/` → `console` | ||
* - `/project-fra-console/` → `console` | ||
* - `/project-nyc-console/` → `console` | ||
*/ | ||
export function getProjectId() { | ||
// safety check! | ||
const projectFromParams = get(page)?.params?.project; | ||
if (projectFromParams) { | ||
return projectFromParams; | ||
} | ||
|
||
const pathname = window.location.pathname + '/'; | ||
const projectMatch = pathname.match(/\/project-(.*?)\//); | ||
const projectMatch = pathname.match(/\/project-(?:[a-z]{2,3}-)?([^/]+)/); | ||
|
||
return projectMatch?.[1] || null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters