Handle bsky.app links natively
This commit is contained in:
parent
b4a8da4c27
commit
f41ba844b3
2 changed files with 16 additions and 3 deletions
|
@ -198,7 +198,7 @@ export function toShortUrl(url: string): string {
|
|||
}
|
||||
}
|
||||
|
||||
export function toShareUrl(url: string) {
|
||||
export function toShareUrl(url: string): string {
|
||||
if (!url.startsWith('https')) {
|
||||
const urlp = new URL('https://bsky.app')
|
||||
urlp.pathname = url
|
||||
|
@ -206,3 +206,15 @@ export function toShareUrl(url: string) {
|
|||
}
|
||||
return url
|
||||
}
|
||||
|
||||
export function convertBskyAppUrlIfNeeded(url: string): string {
|
||||
if (url.startsWith('https://bsky.app/')) {
|
||||
try {
|
||||
const urlp = new URL(url)
|
||||
return urlp.pathname
|
||||
} catch (e) {
|
||||
console.log('Unexpected error in convertBskyAppUrlIfNeeded()', e)
|
||||
}
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue