Skip to content

Commit

Permalink
fix(assets): do not upload assets from same origin (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
purerosefallen authored Feb 11, 2022
1 parent 994f1bb commit 0713f3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugins/assets/local/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class LocalAssets extends Assets {
}

async upload(url: string, file: string) {
if (url.startsWith(this.config.selfUrl)) return url
await this._promise
const { selfUrl, path, root } = this.config
const { buffer, filename } = await this.analyze(url, file)
Expand Down
1 change: 1 addition & 0 deletions plugins/assets/remote/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class RemoteAssets extends Assets {
stop() {}

async upload(url: string, file: string) {
if (url.startsWith(this.config.endpoint)) return url
const { secret } = this.config
const params = { url, file } as any
if (secret) {
Expand Down
3 changes: 3 additions & 0 deletions plugins/assets/s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class S3Assets extends Assets {
}

async upload(url: string, file: string) {
if (url.startsWith(this.config.publicUrl)) {
return url
}
const { buffer, filename } = await this.analyze(url, file)
const s3Key = `${this.config.pathPrefix}${filename}`
const finalUrl = `${this.config.publicUrl}${filename}`
Expand Down

0 comments on commit 0713f3b

Please sign in to comment.