Skip to content

Commit

Permalink
feat: URL Data (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alwinator committed Jan 16, 2024
1 parent 6b1ed12 commit 957344b
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bridgeServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,31 @@ import httpServer from "./httpServer";

class Request {
constructor(rawRequest) {
const urlSplit = rawRequest.url.split('?');

this.requestId = rawRequest.requestId;
this.postData = rawRequest.postData;

if(urlSplit.length > 1){
const regex = /[?&]([^=#]+)=([^&#]*)/g;
const params = {};
let match;
while (match = regex.exec(rawRequest.url)) {
params[match[1]] = match[2];
}
this.getData = params;
}else
this.getData = undefined;

this.type = rawRequest.type;
this.url = rawRequest.url;
this.url = urlSplit[0];
}
get data() {
return JSON.parse(this.postData);
}
get urlData() {
return this.getData;
}
}
class Response {
constructor(requestId) {
Expand Down

0 comments on commit 957344b

Please sign in to comment.