aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/url.js
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2018-06-28 13:45:27 +0200
committerNoah Loomans <noahloomans@gmail.com>2018-06-28 13:45:27 +0200
commit9efc432e160b429a0643c38e28140bcf42af30a7 (patch)
tree2ff1722ed690dc673c8a83cbbf03b40b6526d9f3 /src/client/react/lib/url.js
parent9e55c4b1a151b434cba4b4425514c3aeac6f22d8 (diff)
Add history to redux thunk
Diffstat (limited to 'src/client/react/lib/url.js')
-rw-r--r--src/client/react/lib/url.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/client/react/lib/url.js b/src/client/react/lib/url.js
index 644fd74..fcd3e6a 100644
--- a/src/client/react/lib/url.js
+++ b/src/client/react/lib/url.js
@@ -33,6 +33,16 @@ export function userFromMatch(match) {
return user;
}
+export function userFromLocation(location) {
+ const match = location.pathname.match(/^\/([stcr])\/([-0-9a-zA-Z]+)/);
+ if (!match) return null;
+
+ const user = `${match[1]}/${match[2]}`;
+ if (!users.allIds.includes(user)) return null;
+
+ return user;
+}
+
export function weekFromLocation(location) {
const weekStr = queryString.parse(location.search).week;