summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-11-17 17:25:34 -0200
committerGiovane <giovaneliberato@gmail.com>2015-11-17 17:25:57 -0200
commit591b6e9e3eb2df6c1814438358b29f5eff9d83e1 (patch)
tree4dad99433db92a386293737057fcdbd64c9a60cc
parentc88514fdf18f39fb67101e3ea9741b3430f221b6 (diff)
Consider mail ident characters when parsing routes. #528
-rw-r--r--web-ui/app/js/page/router/url_params.js6
-rw-r--r--web-ui/test/spec/page/router/url_params.spec.js20
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');
});