kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
16 wiersze
319 B
TypeScript
16 wiersze
319 B
TypeScript
![]() |
export function coerceIdentifier(identifier?: string): string | undefined {
|
||
|
if (!identifier) {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
const { pathname } = new URL(identifier)
|
||
|
identifier = pathname
|
||
|
} catch {}
|
||
|
|
||
|
identifier = identifier.replace(/^\//, '')
|
||
|
identifier = identifier.replace(/\/$/, '')
|
||
|
|
||
|
return identifier
|
||
|
}
|