Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Fixed multiple slash in avatar paths (#8074)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzlamateen authored Jun 12, 2023
1 parent 44aefe5 commit 8494db8
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Params } from '@feathersjs/feathers'
import { bodyParser, koa } from '@feathersjs/koa'
import Multer from '@koa/multer'
import { createHash } from 'crypto'
import path from 'path'
import { Op } from 'sequelize'
import { MathUtils } from 'three'

Expand Down Expand Up @@ -145,7 +146,7 @@ export const addGenericAssetToS3AndStaticResources = async (
// make userId optional and safe for feathers create
const key = processFileName(args.key)
const whereArgs = {
[Op.or]: [{ key: key + '/' + files[0].originalname }, { id: args.id ?? '' }]
[Op.or]: [{ key: path.join(key, files[0].originalname) }, { id: args.id ?? '' }]
} as any
if (args.project) whereArgs.project = args.project
const existingAsset = (await app.service('static-resource').Model.findOne({
Expand All @@ -154,7 +155,7 @@ export const addGenericAssetToS3AndStaticResources = async (

const mimeType = CommonKnownContentTypes[extension] as string

const assetURL = getCachedURL(key + '/' + files[0].originalname, provider.cacheDomain)
const assetURL = getCachedURL(path.join(key, files[0].originalname), provider.cacheDomain)
const hash = args.hash || createStaticResourceHash(files[0].buffer, { name: args.name, assetURL })
const body = {
hash,
Expand All @@ -168,7 +169,7 @@ export const addGenericAssetToS3AndStaticResources = async (
// upload asset to storage provider
for (let i = 0; i < files.length; i++) {
const file = files[i]
const useKey = key + '/' + file.originalname
const useKey = path.join(key, file.originalname)
variants.push({
url: getCachedURL(useKey, provider.cacheDomain),
metadata: { size: file.size }
Expand Down

0 comments on commit 8494db8

Please sign in to comment.