Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2019-04-03 15:45:33 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2019-04-03 15:45:33 +0300
commite93edbc24ce1db4a4eda7aecd4474ad09dc40dd1 (patch)
tree7fd26adfb15a39baf0cb45ff33f7edb8cdab8ad9 /src
parent08b40ee0c63b78fd1458e5ab6597a3ddfe351f4d (diff)
Fix parsing of default account message UIDs
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'src')
-rw-r--r--src/tests/unit/util/EnvelopeUidParser.spec.js44
-rw-r--r--src/util/EnvelopeUidParser.js2
2 files changed, 45 insertions, 1 deletions
diff --git a/src/tests/unit/util/EnvelopeUidParser.spec.js b/src/tests/unit/util/EnvelopeUidParser.spec.js
new file mode 100644
index 000000000..42730fda0
--- /dev/null
+++ b/src/tests/unit/util/EnvelopeUidParser.spec.js
@@ -0,0 +1,44 @@
+/*
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import {parseUid} from '../../../util/EnvelopeUidParser'
+
+describe('EnvelopeUidParser', () => {
+ it ('parses a simple UID', () => {
+ const uid = '1-SU5CT1g=-123'
+
+ const parsed = parseUid(uid)
+
+ expect(parsed.accountId).to.equal(1)
+ expect(parsed.folderId).to.equal('SU5CT1g=')
+ expect(parsed.id).to.equal(123)
+ })
+
+ it ('parses the default account UID', () => {
+ const uid = '-2-SU5CT1g=-123'
+
+ const parsed = parseUid(uid)
+
+ expect(parsed.accountId).to.equal(-2)
+ expect(parsed.folderId).to.equal('SU5CT1g=')
+ expect(parsed.id).to.equal(123)
+ })
+})
diff --git a/src/util/EnvelopeUidParser.js b/src/util/EnvelopeUidParser.js
index 38c5115cd..79750d923 100644
--- a/src/util/EnvelopeUidParser.js
+++ b/src/util/EnvelopeUidParser.js
@@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-const reg = /^(\d+)-((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))-(\d+)$/
+const reg = /^(-?\d+)-((?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4}))-(\d+)$/
export const parseUid = str => {
const match = reg.exec(str)