Skip to content

Commit

Permalink
fix: external link support
Browse files Browse the repository at this point in the history
  • Loading branch information
linyibing committed Mar 20, 2024
1 parent 3a8b311 commit 402885a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/periodic/DailyRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,11 @@ export class DailyRecord {
return;
}

const resourceURL =
resource.externalLink ||
`${origin}/o/r/${resource.name || resource.id}`;
if (resource.externalLink) {
return;
}

const resourceURL = `${origin}/o/r/${resource.name || resource.id}`;
const { data } = await this.axios.get(resourceURL, {
responseType: 'arraybuffer',
});
Expand Down
5 changes: 4 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export function formatDailyRecord(record: DailyRecordType) {
}

export function generateFileName(resource: ResourceType): string {
return `${resource.id}-${resource.filename.replace(/[/\\?%*:|"<>]/g, '-')}`;
return (
resource.externalLink ||
`${resource.id}-${resource.filename.replace(/[/\\?%*:|"<>]/g, '-')}`
);
}

export function logMessage(message: string, level: LogLevel = LogLevel.info) {
Expand Down

0 comments on commit 402885a

Please sign in to comment.