mirror of
https://github.com/supabase/supabase.git
synced 2026-05-11 10:49:48 +08:00
* Add db wrappers open in dashboard cta * Restore getLatestRelease return to null * Add guide template components with flexible content positioning * Add Guide components with composition pattern * Remove default branch on tag value * Add GuideTemplate component and do some clean up * Restore original GuideTemplate * Clean up code and unused props * Remove displayName * Remove unwanted export * Refactor EditLink to its own helper file * Apply several fixes * Fix underline on cta button * Remove default main tag * More descriptive button cta label * fix(docs): add iceberg_wrapper dashboard integration --------- Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
40 lines
1021 B
TypeScript
40 lines
1021 B
TypeScript
const EDIT_LINK_SYMBOL = Symbol('edit link')
|
|
|
|
interface EditLink {
|
|
[EDIT_LINK_SYMBOL]: true
|
|
link: string
|
|
includesProtocol: boolean
|
|
}
|
|
|
|
/**
|
|
* Create an object representing a link where the original content can be
|
|
* edited.
|
|
*
|
|
* Takes either a relative path, which will be prefixed with
|
|
* `https://github.com/`, or a full URL including protocol.
|
|
*/
|
|
const newEditLink = (str: string): EditLink => {
|
|
if (str.startsWith('/')) {
|
|
throw Error(`Edit links cannot start with slashes. Received: ${str}`)
|
|
}
|
|
|
|
/**
|
|
* Catch strings that provide FQDNS without https?:
|
|
*
|
|
* At the start of a string, before the first slash, there is a dot
|
|
* surrounded by non-slash characters.
|
|
*/
|
|
if (/^[^\/]+\.[^\/]+\//.test(str)) {
|
|
throw Error(`Fully qualified domain names must start with 'https?'. Received: ${str}`)
|
|
}
|
|
|
|
return {
|
|
[EDIT_LINK_SYMBOL]: true,
|
|
link: str,
|
|
includesProtocol: str.startsWith('http://') || str.startsWith('https://'),
|
|
}
|
|
}
|
|
|
|
export { newEditLink }
|
|
export type { EditLink }
|