diff --git a/dev/Common/Links.js b/dev/Common/Links.js index 12279c6c5..0c1ec3b2f 100644 --- a/dev/Common/Links.js +++ b/dev/Common/Links.js @@ -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('/'); }; diff --git a/dev/Screen/User/MailBox.js b/dev/Screen/User/MailBox.js index 92dfb8de5..aa74e160a 100644 --- a/dev/Screen/User/MailBox.js +++ b/dev/Screen/User/MailBox.js @@ -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 }] ]; }