Skip to content

Commit c16602c

Browse files
authored
fix(postgrest): validate empty or invalid relation names in Postgrest… (#1863)
1 parent 612625d commit c16602c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

packages/core/postgrest-js/src/PostgrestClient.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ export default class PostgrestClient<
8888
* @param relation - The table or view name to query
8989
*/
9090
from(relation: string): PostgrestQueryBuilder<ClientOptions, Schema, any, any> {
91+
if (!relation || typeof relation !== 'string' || relation.trim() === '') {
92+
throw new Error('Invalid relation name: relation must be a non-empty string.')
93+
}
94+
9195
const url = new URL(`${this.url}/${relation}`)
9296
return new PostgrestQueryBuilder(url, {
9397
headers: new Headers(this.headers),

0 commit comments

Comments
 (0)