-
-
Notifications
You must be signed in to change notification settings - Fork 37
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 #553 from zacharyhansen/fix/support-self-hosted-po…
…stgrest fix: merge url splitting to unified method that handles self hosted s…
- Loading branch information
Showing
4 changed files
with
29 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@supabase-cache-helpers/postgrest-core": minor | ||
--- | ||
|
||
Merge url parsing for rpc and table name and provide consistant parsing for self hosted servers |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Parses a url and returns the table name the url is interacting with. | ||
* | ||
* For mutations, the .split('?') goes unused. | ||
* | ||
* @param url The url we are pulling the table name from | ||
* @returns Table name | ||
*/ | ||
export const getTableFromUrl = (url: string): string => { | ||
// Split the url | ||
const split = url.toString().split('/'); | ||
// Pop the last part of the path off and remove any params if they exist | ||
const table = split.pop()?.split('?').shift() as string; | ||
// Pop an additional position to check for rpc | ||
const maybeRpc = split.pop() as string; | ||
// Rejoin the result to include rpc otherwise just table name | ||
return [maybeRpc === 'rpc' ? maybeRpc : null, table] | ||
.filter(Boolean) | ||
.join('/'); | ||
}; |
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