Skip to content

Commit e1853b4

Browse files
committed
doc/config: remove usage of M/Y expiration units, set default expiration to 7d
1 parent da68198 commit e1853b4

File tree

6 files changed

+7
-11
lines changed

6 files changed

+7
-11
lines changed

doc/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Upload your paste. It accept parameters in form-data:
124124

125125
- `c`: mandatory. The **content** of your paste, text of binary. It should be no larger than 10 MB. The `filename` in its `Content-Disposition` will be present when fetching the paste.
126126

127-
- `e`: optional. The **expiration** time of the paste. After this period of time, the paste is permanently deleted. It should be an integer or a float point number suffixed with an optional unit (seconds by default). Supported units: `s` (seconds), `m` (minutes), `h` (hours), `d` (days), `M` (months). For example, `360.24` means 360.25 seconds; `25d` is interpreted as 25 days. The actual expiration might be shorter than specified expiration due to limitations imposed by the administrator. If unspecified, a default expiration time setting is used.
127+
- `e`: optional. The **expiration** time of the paste. After this period of time, the paste is permanently deleted. It should be an integer or a float point number suffixed with an optional unit (seconds by default). Supported units: `s` (seconds), `m` (minutes), `h` (hours), `d` (days). For example, `360.24` means 360.25 seconds; `25d` is interpreted as 25 days. The actual expiration might be shorter than specified expiration due to limitations imposed by the administrator. If unspecified, a default expiration time setting is used.
128128

129129
- `s`: optional. The **password** which allows you to modify and delete the paste. If not specified, the worker will generate a random string as password.
130130

frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ <h2>Settings</h2>
4242
<div id='paste-expiration-panel' class='paste-setting-subitem-panel'>
4343
<input list='expiration-choices' type='text' min='60' step='1' name='paste-expiration'
4444
id='paste-expiration-input' placeholder='Expiration (secs)' value='7d'>
45-
<label class='small-label' for='paste-expiration-input'>Delete your paste after a period of time (leave blank for no expiry). <br>Units: s (seconds), m (minutes), h (hours), d (days), M (months), Y (years)</label>
45+
<label class='small-label' for='paste-expiration-input'>Delete your paste after a period of time (leave blank for no expiry). <br>Units: s (seconds), m (minutes), h (hours), d (days)</label>
4646
</div>
4747
<div id='paste-passwd-panel' class='paste-setting-subitem-panel'>
4848
<input type='text' spellcheck='false' name='paste-expiration' id='paste-passwd-input' placeholder='Password'>

src/common.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export function parsePath(pathname: string): ParsedPath {
112112
}
113113

114114
export function parseExpiration(expirationStr: string): number {
115-
const EXPIRE_REGEX = /^[\d.]+\s*[smhdwMY]?$/
115+
const EXPIRE_REGEX = /^[\d.]+\s*[smhd]?$/
116116
if (!EXPIRE_REGEX.test(expirationStr)) {
117117
throw new WorkerError(400, `‘${expirationStr}’ is not a valid expiration specification`)
118118
}
@@ -122,9 +122,6 @@ export function parseExpiration(expirationStr: string): number {
122122
if (lastChar === 'm') expirationSeconds *= 60
123123
else if (lastChar === 'h') expirationSeconds *= 3600
124124
else if (lastChar === 'd') expirationSeconds *= 3600 * 24
125-
else if (lastChar === 'w') expirationSeconds *= 3600 * 24 * 7
126-
else if (lastChar === 'M') expirationSeconds *= 3600 * 24 * 30
127-
else if (lastChar === 'Y') expirationSeconds *= 3600 * 24 * 365
128125
return expirationSeconds
129126
}
130127

test/basic.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ test("expire", async () => {
133133
await testExpireParse("100m", 6000)
134134
await testExpireParse("100h", 360000)
135135
await testExpireParse("1d", 86400)
136-
await testExpireParse("1M", 2592000)
137-
await testExpireParse("1Y", 2592000) // longer expiration will be clipped to 30d
136+
await testExpireParse("100d", 2592000) // longer expiration will be clipped to 30d
138137
await testExpireParse("100 m", 6000)
139138
await testExpireParse("", 1209600)
140139

worker-configuration.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable */
2-
// Generated by Wrangler by running `wrangler types` (hash: efea6d6ac4797dcaa89982c8d3bad6a2)
2+
// Generated by Wrangler by running `wrangler types` (hash: 6f4508d8d2a1a6ac44ffda519020bb4d)
33
// Runtime types generated with [email protected] 2023-01-28
44
declare namespace Cloudflare {
55
interface Env {
@@ -11,7 +11,7 @@ declare namespace Cloudflare {
1111
TOS_MAIL: "[email protected]";
1212
CACHE_STATIC_PAGE_AGE: 7200;
1313
CACHE_PASTE_AGE: 600;
14-
DEFAULT_EXPIRATION: "14d";
14+
DEFAULT_EXPIRATION: "7d";
1515
MAX_EXPIRATION: "30d";
1616
BASIC_AUTH: {};
1717
}

wrangler.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ CACHE_STATIC_PAGE_AGE = 7200
4646
CACHE_PASTE_AGE = 600
4747

4848
# Default expiration
49-
DEFAULT_EXPIRATION = "14d"
49+
DEFAULT_EXPIRATION = "7d"
5050

5151
# Max expiration
5252
MAX_EXPIRATION = "30d"

0 commit comments

Comments
 (0)