Skip to content

Commit

Permalink
Add support for path prefix within buckets (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
big213 authored Oct 4, 2020
1 parent 8dee77e commit 2d08adc
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 16 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module.exports.img = createHandler({
// Where the source images are located.
// E.g. gs://s.example.com/image.jpg
sourceBucket: "s.example.com",

// Where the transformed images needs to be stored.
// E.g. gs://c.example.com/image__w_80,h_60.jpg
cacheBucket: "c.example.com",
Expand Down
32 changes: 27 additions & 5 deletions lib/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/main.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/parse.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
*/
import { Params, ParsedOutput } from "./types";
export declare function parseUrlPath(path: string, params: Readonly<Params>): ParsedOutput;
/**
* Extracts folder name (prefix) from the bucket name.
*
* @example
* parseBucket("gs://s.example.com") => ["gs://s.example.com", ""]
* parseBucket("gs://s.example.com/") => ["gs://s.example.com", ""]
* parseBucket("gs://s.example.com/uploads") => ["gs://s.example.com", "uploads/"]
* parseBucket("gs://s.example.com/uploads/") => ["gs://s.example.com", "uploads/"]
*/
export declare function parseBucket(value: string): [bucket: string, prefix: string];
27 changes: 27 additions & 0 deletions lib/parse.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2d08adc

Please sign in to comment.