• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-js / 16913742507

12 Aug 2025 03:41PM UTC coverage: 74.8%. Remained the same
16913742507

push

github

web-flow
chore: add preview release (#1530)

65 of 104 branches covered (62.5%)

Branch coverage included in aggregate %.

122 of 146 relevant lines covered (83.56%)

34.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/lib/helpers.ts
1
// helpers.ts
2
import { SupabaseClientOptions } from './types'
3

4
export function uuid() {
39✔
5
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
3✔
6
    var r = (Math.random() * 16) | 0,
93✔
7
      v = c == 'x' ? r : (r & 0x3) | 0x8
93✔
8
    return v.toString(16)
93✔
9
  })
10
}
11

12
export function ensureTrailingSlash(url: string): string {
39✔
13
  return url.endsWith('/') ? url : url + '/'
69✔
14
}
15

16
export const isBrowser = () => typeof window !== 'undefined'
39✔
17

18
export function applySettingDefaults<
39✔
19
  Database = any,
20
  SchemaName extends string & keyof Database = 'public' extends keyof Database
21
    ? 'public'
22
    : string & keyof Database
23
>(
24
  options: SupabaseClientOptions<SchemaName>,
25
  defaults: SupabaseClientOptions<any>
26
): Required<SupabaseClientOptions<SchemaName>> {
27
  const {
28
    db: dbOptions,
29
    auth: authOptions,
30
    realtime: realtimeOptions,
31
    global: globalOptions,
32
  } = options
60✔
33
  const {
34
    db: DEFAULT_DB_OPTIONS,
35
    auth: DEFAULT_AUTH_OPTIONS,
36
    realtime: DEFAULT_REALTIME_OPTIONS,
37
    global: DEFAULT_GLOBAL_OPTIONS,
38
  } = defaults
60✔
39

40
  const result: Required<SupabaseClientOptions<SchemaName>> = {
60✔
41
    db: {
42
      ...DEFAULT_DB_OPTIONS,
43
      ...dbOptions,
44
    },
45
    auth: {
46
      ...DEFAULT_AUTH_OPTIONS,
47
      ...authOptions,
48
    },
49
    realtime: {
50
      ...DEFAULT_REALTIME_OPTIONS,
51
      ...realtimeOptions,
52
    },
53
    storage: {},
54
    global: {
55
      ...DEFAULT_GLOBAL_OPTIONS,
56
      ...globalOptions,
57
      headers: {
58
        ...(DEFAULT_GLOBAL_OPTIONS?.headers ?? {}),
360!
59
        ...(globalOptions?.headers ?? {}),
360✔
60
      },
61
    },
62
    accessToken: async () => '',
×
63
  }
64

65
  if (options.accessToken) {
60✔
66
    result.accessToken = options.accessToken
3✔
67
  } else {
68
    // hack around Required<>
69
    delete (result as any).accessToken
57✔
70
  }
71

72
  return result
60✔
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc