mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-02 21:12:02 +08:00
easier mailBox() link generator
This commit is contained in:
parent
df293960d0
commit
c41adf35f5
2 changed files with 9 additions and 7 deletions
|
@ -118,23 +118,23 @@ export const
|
|||
* @param {number=} threadUid = 0
|
||||
* @returns {string}
|
||||
*/
|
||||
mailBox = (folder, page = 1, search = '', threadUid = 0) => {
|
||||
mailBox = (folder, page, search, threadUid) => {
|
||||
page = pInt(page, 1);
|
||||
search = pString(search);
|
||||
|
||||
let result = HASH_PREFIX + 'mailbox/';
|
||||
let result = [HASH_PREFIX + 'mailbox'];
|
||||
|
||||
if (folder) {
|
||||
result += encodeURI(folder) + (threadUid ? '~' + threadUid : '');
|
||||
result.push(folder + (threadUid ? '~' + threadUid : ''));
|
||||
}
|
||||
|
||||
if (1 < page) {
|
||||
result = result.replace(/\/+$/, '') + '/p' + page;
|
||||
result.push('p' + page);
|
||||
}
|
||||
|
||||
if (search) {
|
||||
result = result.replace(/\/+$/, '') + '/' + encodeURI(search);
|
||||
result.push(encodeURI(search));
|
||||
}
|
||||
|
||||
return result;
|
||||
return result.join('/');
|
||||
};
|
||||
|
|
|
@ -134,11 +134,13 @@ export class MailBoxUserScreen extends AbstractScreen {
|
|||
fNormS = (request, vals) => [folder(request, vals), request ? pInt(vals[1]) : 1, decodeURI(pString(vals[2]))];
|
||||
|
||||
return [
|
||||
// Folder: INBOX | INBOX.sub | Sent | fullNameHash
|
||||
[/^([^/]*)$/, { normalize_: fNormS }],
|
||||
// Regex the fullNameHash
|
||||
// Search: {folder}/{string}
|
||||
[/^([a-zA-Z0-9.~_-]+)\/(.+)\/?$/, { normalize_: (request, vals) =>
|
||||
[folder(request, vals), 1, decodeURI(pString(vals[1]))]
|
||||
}],
|
||||
// Page: {folder}/p{int}(/{search})?
|
||||
[/^([a-zA-Z0-9.~_-]+)\/p([1-9][0-9]*)(?:\/(.+)\/?)?$/, { normalize_: fNormS }]
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue