This repository has been archived on 2026-09-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
KSnippets/snippets-frontend/lib/snippet-utils.ts
T
2026-08-27 20:13:42 +08:00

13 lines
501 B
TypeScript

export function languageLabel(filename: string) {
const extension = filename.split('.').pop()?.toUpperCase()
return extension && extension.length <= 6 ? extension : 'TEXT'
}
export function rawSnippetUrl(id: string) {
return `http://127.0.0.1:6868/${encodeURIComponent(id)}?mode=raw`
}
export function snippetUrl(id: string) {
if (typeof window === 'undefined') return `/${encodeURIComponent(id)}`
return new URL(`/${encodeURIComponent(id)}`, window.location.origin).toString()
}