Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/viewing stored attachment #109

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).

- Included test cases for malware scanning within development profile.

### Fixed

- Fix for viewing stored attachment.

## Version 1.1.7

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const cds = require("@sap/cds/lib");
const LOG = cds.log("attachments");
const { extname } = require("path");
const DEBUG = LOG._debug ? LOG.debug : undefined;
const attachmentIDRegex = /attachments\(.*ID=([^,]+),.*\)/;
const attachmentIDRegex = /\/\w+\(.*ID=([0-9a-fA-F-]{36})/;

cds.on("loaded", function unfoldModel(csn) {
if (!("Attachments" in csn.definitions)) return;
Expand Down Expand Up @@ -68,7 +68,7 @@ cds.once("served", async function registerPluginHandlers() {
});

if(req?.req?.url?.endsWith("/content")) {
const attachmentID = req.req.url.match(attachmentIDRegex)[1];
const attachmentID = req. req.url.match(attachmentIDRegex)[1];
const status = await AttachmentsSrv.getStatus(req.target, { ID : attachmentID });
const scanEnabled = cds.env.requires?.attachments?.scan ?? true
if(scanEnabled && status !== 'Clean') {
Expand Down
Loading