From 591b6e9e3eb2df6c1814438358b29f5eff9d83e1 Mon Sep 17 00:00:00 2001 From: Giovane Date: Tue, 17 Nov 2015 17:25:34 -0200 Subject: Consider mail ident characters when parsing routes. #528 --- web-ui/app/js/page/router/url_params.js | 6 +++--- web-ui/test/spec/page/router/url_params.spec.js | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web-ui/app/js/page/router/url_params.js b/web-ui/app/js/page/router/url_params.js index 6521ef43..4fa11c6d 100644 --- a/web-ui/app/js/page/router/url_params.js +++ b/web-ui/app/js/page/router/url_params.js @@ -27,7 +27,7 @@ define([], function () { function hashTag(hash) { if (hasMailIdent(hash)) { - return /\/(.+)\/mail\/[A-Z0-9]+$/.exec(getDocumentHash())[1]; + return /\/(.+)\/mail\/[-\w]+$/.exec(getDocumentHash())[1]; } return hash.substring(2); } @@ -41,11 +41,11 @@ define([], function () { } function hasMailIdent() { - return getDocumentHash().match(/mail\/[A-Z0-9]+$/); + return getDocumentHash().match(/mail\/[-\w]+$/); } function getMailIdent() { - return /mail\/([A-Z0-9]+)$/.exec(getDocumentHash())[1]; + return /mail\/([-\w]+)$/.exec(getDocumentHash())[1]; } return { diff --git a/web-ui/test/spec/page/router/url_params.spec.js b/web-ui/test/spec/page/router/url_params.spec.js index 45f8c382..24cc3797 100644 --- a/web-ui/test/spec/page/router/url_params.spec.js +++ b/web-ui/test/spec/page/router/url_params.spec.js @@ -21,25 +21,25 @@ require(['page/router/url_params'], function (urlParams) { }); it('returns the tag in the hash if there is one', function () { - document.location.hash = '/Drafts'; + document.location.hash = '#/Drafts'; expect(urlParams.getTag()).toEqual('Drafts'); }); it('returns tag with slash', function () { - document.location.hash = '/Events/2011'; + document.location.hash = '#/Events/2011'; expect(urlParams.getTag()).toEqual('Events/2011'); }); it('returns tag even if there is an mail ident', function () { - document.location.hash = '/Events/2011/mail/1'; + document.location.hash = '#/events/2011/mail/M-123_abc'; - expect(urlParams.getTag()).toEqual('Events/2011'); + expect(urlParams.getTag()).toEqual('events/2011'); }); it('returns the tag even if there is a trailing slash', function () { - document.location.hash = '/Events/'; + document.location.hash = '#/Events/'; expect(urlParams.getTag()).toEqual('Events'); }); @@ -47,13 +47,13 @@ require(['page/router/url_params'], function (urlParams) { describe('hasMailIdent', function () { it('is true if hash has mailIdent', function () { - document.location.hash = '/inbox/mail/1'; + document.location.hash = '#/inbox/mail/M-123_abc'; expect(urlParams.hasMailIdent()).toBeTruthy(); }); it('is false if hash has no mail ident', function () { - document.location.hash = '/Drafts'; + document.location.hash = '#/Drafts'; expect(urlParams.hasMailIdent()).toBeFalsy(); }); @@ -61,13 +61,13 @@ require(['page/router/url_params'], function (urlParams) { describe('getMailIdent', function () { it('returns the mail ident that is in the hash', function () { - document.location.hash = '/inbox/mail/123'; + document.location.hash = '#/inbox/mail/M-123_abc'; - expect(urlParams.getMailIdent()).toEqual('123'); + expect(urlParams.getMailIdent()).toEqual('M-123_abc'); }); it('supports uppercase letters and numbers as mail id', function () { - document.location.hash = '/inbox/mail/123ASDADA'; + document.location.hash = '#/inbox/mail/123ASDADA'; expect(urlParams.getMailIdent()).toEqual('123ASDADA'); }); -- cgit v1.2.3