Skip to content

Commit

Permalink
Remove key prefix from public url
Browse files Browse the repository at this point in the history
  • Loading branch information
eandre committed Nov 29, 2024
1 parent feeadd1 commit e7a710b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
2 changes: 1 addition & 1 deletion runtimes/core/src/objects/gcs/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl objects::ObjectImpl for Object {
return Err(PublicUrlError::PrivateBucket);
};

let url = objects::public_url(base_url, self.bkt.key_prefix.as_deref(), &self.key);
let url = objects::public_url(base_url, &self.key);
Ok(url)
}
}
Expand Down
7 changes: 2 additions & 5 deletions runtimes/core/src/objects/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,16 +493,13 @@ fn escape_path(s: &str) -> Cow<'_, str> {
percent_encoding::percent_encode(s.as_bytes(), PATH).into()
}

/// Computes the public url given a base url, optional key prefix, and object name.
fn public_url(base_url: String, key_prefix: Option<&str>, name: &str) -> String {
/// Computes the public url given a base url and object name.
fn public_url(base_url: String, name: &str) -> String {
let mut url = base_url;

if !url.ends_with('/') {
url.push('/');
}
if let Some(key_prefix) = key_prefix {
url.push_str(&escape_path(key_prefix));
}
url.push_str(&escape_path(name));
url
}
2 changes: 1 addition & 1 deletion runtimes/core/src/objects/s3/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl objects::ObjectImpl for Object {
return Err(PublicUrlError::PrivateBucket);
};

let url = objects::public_url(base_url, self.bkt.key_prefix.as_deref(), &self.name);
let url = objects::public_url(base_url, &self.name);
Ok(url)
}
}
Expand Down
5 changes: 0 additions & 5 deletions runtimes/go/storage/objects/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,6 @@ func (b *Bucket) PublicURL(object string, options ...PublicURLOption) *url.URL {
if !strings.HasSuffix(u.Path, "/") {
u.Path += "/"
}

if b.runtimeCfg.KeyPrefix != "" {
u.Path += escape(b.runtimeCfg.KeyPrefix, encodePath)
}

u.Path += escape(object, encodePath)

return &u
Expand Down

0 comments on commit e7a710b

Please sign in to comment.