aboutsummaryrefslogtreecommitdiff
path: root/src/client/react/lib/url.js
diff options
context:
space:
mode:
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;