Skip to content

Commit

Permalink
Fix: revert and diss decodeURIComponent (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Leslie-Wong-H authored Jun 3, 2023
2 parents 849eb32 + dc899c7 commit b93496f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,7 @@ export default async (req, res) => {
const params = {
Bucket: AWS_BUCKET,
// Key: `${req.params.imdbID}/${req.params.filename.replace(/\.jpg$/, "")}`,
Key: `hls/${req.params.imdbID}/${decodeURIComponent(
req.params.filename.replace(/\.jpg$/, "")
)}/index.m3u8`,
Key: `hls/${req.params.imdbID}/${req.params.filename.replace(/\.jpg$/, "")}/index.m3u8`,
};
try {
command = new HeadObjectCommand(params);
Expand Down
5 changes: 2 additions & 3 deletions src/list.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { S3Client, ListObjectsCommand } from "@aws-sdk/client-s3";
import sanitize from "sanitize-filename";

const { AWS_ENDPOINT_URL, AWS_ACCESS_KEY, AWS_SECRET_KEY, AWS_BUCKET, AWS_REGION } = process.env;

Expand Down Expand Up @@ -47,9 +46,9 @@ export default async (req, res) => {
}, {});

if (reqParams.imdbID) {
params.Prefix += sanitize(reqParams.imdbID);
params.Prefix += reqParams.imdbID;
if (reqParams.filename) {
params.Prefix += "/" + decodeURIComponent(sanitize(reqParams.filename));
params.Prefix += "/" + decodeURIComponent(reqParams.filename);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default async (req, res) => {
const params = {
Bucket: AWS_BUCKET,
// Key: `${req.params.imdbID}/${req.params.filename}`,
Key: `hls/${req.params.imdbID}/${decodeURIComponent(req.params.filename)}/index.m3u8`,
Key: `hls/${req.params.imdbID}/${req.params.filename}/index.m3u8`,
};
try {
command = new HeadObjectCommand(params);
Expand Down Expand Up @@ -90,7 +90,7 @@ export default async (req, res) => {
signedUrl,
scene.start,
scene.end,
`hls/${req.params.imdbID}/${decodeURIComponent(req.params.filename)}`,
`hls/${req.params.imdbID}/${req.params.filename}`,
size,
"mute" in req.query
);
Expand Down

0 comments on commit b93496f

Please sign in to comment.