memos/web/src/utils/resource.ts
2023-01-21 08:46:49 +08:00

7 lines
254 B
TypeScript

export const getResourceUrl = (resource: Resource, withOrigin = true) => {
if (resource.externalLink) {
return resource.externalLink;
}
return `${withOrigin ? window.location.origin : ""}/o/r/${resource.id}/${encodeURI(resource.filename)}`;
};