Skip to content

Commit

Permalink
bug: fix bug with rendering = signs
Browse files Browse the repository at this point in the history
  • Loading branch information
georgetayqy committed Nov 13, 2024
1 parent 515c625 commit 3915c1c
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions collaboration-service/src/server/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,25 +436,16 @@ const getTemplateQuestion = (url) => {
return null;
}

// remove url splits that result in empty strings
// decode to split properly
url = decodeURIComponent(url);
const splitUrl = url.split(/[&|?|/]/).filter((val, x, y) => val.length > 0);

let templateCode = '';
let userId = '';

// iterate through the url entries and populate accordingly
for (const urlEntry of splitUrl) {
if (urlEntry.startsWith('templateCode')) {
templateCode = urlEntry.split('=')[1];
} else if (urlEntry.startsWith('userId')) {
userId = urlEntry.split('=')[1];
}
}
// use regex to get the correct component
const userId = url.split('userId=')[1];
const templateCode = url.split('templateCode=')[1].split('&userId=')[0];

return [
templateCode.length == 0 ? null : templateCode,
userId.length == 0 ? 'defaultUser' : userId,
templateCode?.length == 0 ? null : templateCode,
userId?.length == 0 ? 'defaultUser' : userId,
];
};

Expand All @@ -466,5 +457,5 @@ export {
WSSharedDoc,
getYDoc,
setupWSConnection,
deleted
deleted,
};

0 comments on commit 3915c1c

Please sign in to comment.