- Refactored SharePanel to retrieve the share URL directly from the entry data. - Enhanced UrlBuilder with a new method for generating share URLs that includes view and subscription parameters. - Updated the shareEntry method to utilize the new structure for better flexibility. Signed-off-by: Innei <tukon479@gmail.com>
24 lines
717 B
TypeScript
24 lines
717 B
TypeScript
export class UrlBuilder {
|
|
constructor(private readonly webUrl: string) {}
|
|
protected join(path: string, query?: Record<string, string>) {
|
|
const nextUrl = new URL(this.webUrl)
|
|
nextUrl.pathname = path
|
|
if (query) {
|
|
for (const [key, value] of Object.entries(query)) {
|
|
nextUrl.searchParams.set(key, value)
|
|
}
|
|
}
|
|
return nextUrl.toString()
|
|
}
|
|
shareFeed(id: string, view?: number) {
|
|
return this.join(`share/feeds/${id}`, view ? { view: view.toString() } : undefined)
|
|
}
|
|
shareList(id: string, view?: number) {
|
|
return this.join(`share/lists/${id}`, view ? { view: view.toString() } : undefined)
|
|
}
|
|
|
|
profile(id: string) {
|
|
return this.join(`share/users/${id}`)
|
|
}
|
|
}
|