Skip to content

Commit

Permalink
fix: unify handling of suggestUrl, also update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
SharzyL committed Mar 10, 2024
1 parent 7c14e8a commit 8ddd88c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
11 changes: 6 additions & 5 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ Upload your paste. It accept parameters in form-data:

Explanation of the fields:

- `url`: mandatory. The URL to fetch the paste. When using a customized name, it looks like `https//shz.al/~myname`.
- `admin`: mandatory. The URL to update and delete the paste, which is `url` suffixed by `~` and the password.
- `expire`: optional. The expiration seconds.
- `isPrivate`: mandatory. Whether the paste is in private mode.
- `url`: String. The URL to fetch the paste. When using a customized name, it looks like `https//shz.al/~myname`.
- `suggestUrl`: String or null. The URL that may carry filename or URL redirection.
- `admin`: String. The URL to update and delete the paste, which is `url` suffixed by `~` and the password.
- `expire`: String or null. The expiration seconds.
- `isPrivate`: Bool. Whether the paste is in private mode.

If error occurs, the worker returns status code different from `200`:

Expand Down Expand Up @@ -193,7 +194,7 @@ Update you paste of the name `<name>` and password `<passwd>`. It accept the par
- `e`: optional. Same as `POST` method. Note that the deletion time is now recalculated.
- `s`: optional. Same as `POST` method.

The returning of `PUT` method is also the same as `POST` method.
The returning of `PUT` method is the same as `POST` method.

If error occurs, the worker returns status code different from `200`:

Expand Down
3 changes: 3 additions & 0 deletions frontend/index.client.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ window.addEventListener('DOMContentLoaded', () => {
$('#paste-uploaded-panel').removeClass('hidden')
$('#uploaded-url').prop('value', uploaded.url)
$('#uploaded-admin-url').prop('value', uploaded.admin)
if (uploaded.suggestUrl) {
$('#uploaded-suggest-url').prop('value', uploaded.suggestUrl)
}
if (uploaded.expire) {
$('#uploaded-expiration').prop('value', uploaded.expire)
}
Expand Down
9 changes: 7 additions & 2 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,16 @@ <h2>Uploaded paste</h2>
<input id='uploaded-admin-url' type='text' class='uploaded-table-text' readonly>
<button class='copy-button'>Copy</button>
</div>
<label for='uploaded-admin-url' class='small-label'>Admin URL</label>
<label for='suggest-url' class='small-label'>Admin URL</label>
<div class='uploaded-entry'>
<input id='uploaded-suggest-url' type='text' class='uploaded-table-text' readonly>
<button class='copy-button'>Copy</button>
</div>
<label for='uploaded-admin-url' class='small-label'>Suggest URL</label>
<div class='uploaded-entry'>
<input type='text' id='uploaded-expiration' class='uploaded-table-text' readonly>
</div>
<label for='uploaded-expiration' class='small-label'>Expiration</label>
<label for='uploaded-expiration' class='small-label'>Expiration (secs)</label>
</div>
<div>
<button id='submit-button' class='long-button px-3 py-2 my-1'>Upload</button>
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ async function createPaste(env, content, isPrivate, expire, short, date, passwd,
suggestUrl: suggestUrl(content, filename, short, env.BASE_URL),
admin: adminUrl,
isPrivate: isPrivate,
expire: expire,
expire: expire || null,
}
}

Expand Down

0 comments on commit 8ddd88c

Please sign in to comment.