Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Fix typo and add comments, fix #10
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong authored Sep 25, 2019
1 parent 11aec2c commit 587cb2e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/http/TargetExtractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as http from 'http';
import URL from 'url';
import ResourceIdentifier from '../ldp/IResourceIdentifier';

// TODO: This RegEx could be improved:
const VALID_HOST = /^([a-z0-9-]+\.)*[a-z0-9-]+$/;

/**
Expand All @@ -29,11 +30,13 @@ export default class TargetExtractor {
public extract(request: http.IncomingMessage): ResourceIdentifier {
// Extract path
const { pathname } = URL.parse(request.url || '');
const path = decodeURI(pathname || '/').replace(/(?<=.)\/+$/, '');
const path = decodeURIComponent(pathname || '/').replace(/(?<=.)\/+$/, '');
if (path.indexOf('/..') >= 0) {
throw new Error(`Disallowed /.. segment in URL ${pathname}`);
}
// Determine whether this is the path to an ACL resource
// Note that this enshrines certain assumptions about the server's
// system for naming ACL documents, see https://github.com/inrupt/solid-server-ts/issues/10
const isAcl = path.endsWith(this.aclExtension);

// Extract domain
Expand Down

0 comments on commit 587cb2e

Please sign in to comment.