Skip to content

Commit

Permalink
fix: replace url-join with path.posix.join (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
sodatea authored and michael-ciniawsky committed Sep 21, 2018
1 parent 0f9e2e7 commit d75802b
Show file tree
Hide file tree
Showing 5 changed files with 465 additions and 492 deletions.
4 changes: 2 additions & 2 deletions lib/middleware.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const path = require('path');
const mime = require('mime');
const urlJoin = require('url-join');
const DevMiddlewareError = require('./DevMiddlewareError');
const { getFilenameFromUrl, handleRangeHeaders, handleRequest, ready } = require('./util');

Expand Down Expand Up @@ -52,7 +52,7 @@ module.exports = function wrapper(context) {
throw new DevMiddlewareError('next');
}

filename = urlJoin(filename, index);
filename = path.posix.join(filename, index);
stat = context.fs.statSync(filename);
if (!stat.isFile()) {
throw new DevMiddlewareError('next');
Expand Down
5 changes: 2 additions & 3 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const path = require('path');
const { parse } = require('url');
const querystring = require('querystring');
const parseRange = require('range-parser');
const urlJoin = require('url-join');

const HASH_REGEXP = /[0-9a-f]{10,}/;

Expand Down Expand Up @@ -92,7 +91,7 @@ module.exports = {
if (process.platform === 'win32') {
// Path Handling for Microsoft Windows
if (filename) {
uri = urlJoin((outputPath || ''), querystring.unescape(filename));
uri = path.posix.join((outputPath || ''), querystring.unescape(filename));

if (!path.win32.isAbsolute(uri)) {
uri = `/${uri}`;
Expand All @@ -104,7 +103,7 @@ module.exports = {

// Path Handling for all other operating systems
if (filename) {
uri = urlJoin((outputPath || ''), filename);
uri = path.posix.join((outputPath || ''), filename);

if (!path.posix.isAbsolute(uri)) {
uri = `/${uri}`;
Expand Down

0 comments on commit d75802b

Please sign in to comment.