Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode the requested url #654

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dist/** -diff
yarn.lock -diff

* text=false
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apt-get update

# required by lint script
RUN apt-get -y install jq
RUN apt-get -y install vim

# https://github.com/buildkite/docker-puppeteer/blob/master/Dockerfile
RUN apt-get update \
Expand All @@ -32,3 +33,6 @@ RUN apt-get update \
COPY . /xviz/

RUN yarn bootstrap

EXPOSE 3000
ENTRYPOINT ["/xviz/modules/server/bin/xvizserver", "--port", "3000", "-d", "/"]
15 changes: 12 additions & 3 deletions modules/server/src/server/xviz-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ function getRequestData(requestUrl) {
}

return {
path: req.pathname,
path: decodeUrl(req.pathname),
params
};
}

function decodeUrl(url) {
const decodedUrl = decodeURI(url)
if (decodedUrl[1] === '/') {
return decodedUrl.substring(1)
}

return decodedUrl
}

// TODO: Allow a client supplied server to be used
// so clients can control routes
const DEFAULT_OPTIONS = {
Expand Down Expand Up @@ -58,8 +67,8 @@ export class XVIZServer {
}

async handleSession(socket, request) {
this.log(`[> Connection] created: ${request.url}`);
const req = getRequestData(request.url);
const decodedUrl = decodeUrl(request.url)
const req = getRequestData(decodedUrl);

for (const handler of this.handlers) {
const session = await handler.newSession(socket, req);
Expand Down