Commit 4fcdf9b9 authored by Paul Kaplan's avatar Paul Kaplan

Allow URLs to be passed for the project input

parent 4f6a5832
...@@ -59,8 +59,17 @@ const generateProjectListItem = (postBody, infoBody) => ({ ...@@ -59,8 +59,17 @@ const generateProjectListItem = (postBody, infoBody) => ({
username: infoBody.author.username, username: infoBody.author.username,
avatar: infoBody.author.profile.images avatar: infoBody.author.profile.images
}); });
const addProject = projectId => ((dispatch, getState) => new Promise((resolve, reject) => { const addProject = projectIdOrUrl => ((dispatch, getState) => new Promise((resolve, reject) => {
// Strings are passed by the open input, numbers by the project browser
let projectId = projectIdOrUrl;
if (typeof projectIdOrUrl === 'string') {
const matches = projectIdOrUrl.match(/(\d+)/g);
if (!matches) return reject(Errors.UNKNOWN_PROJECT);
// Take the last match, in case we are on localhost and there are port numbers, e.g.
projectId = parseInt(matches[matches.length - 1], 10);
}
const state = getState(); const state = getState();
const studioId = selectStudioId(state); const studioId = selectStudioId(state);
const token = selectToken(state); const token = selectToken(state);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment