mirror of
https://github.com/enso-org/enso.git
synced 2024-12-03 21:43:48 +03:00
23 lines
449 B
TypeScript
23 lines
449 B
TypeScript
|
/**
|
||
|
* @file Utility methods for ydoc server authentication.
|
||
|
*/
|
||
|
|
||
|
export type ConnectionData = {
|
||
|
lsUrl: string
|
||
|
doc: string
|
||
|
user: string
|
||
|
}
|
||
|
|
||
|
const docNameRegex = /^[a-z0-9/-]+$/i
|
||
|
|
||
|
export function docName(pathname: string) {
|
||
|
const prefix = '/project/'
|
||
|
if (pathname != null && pathname.startsWith(prefix)) {
|
||
|
const docName = pathname.slice(prefix.length)
|
||
|
if (docNameRegex.test(docName)) {
|
||
|
return docName
|
||
|
}
|
||
|
}
|
||
|
return null
|
||
|
}
|