forked from webpack/webpack-dev-middleware
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/webpack/webpack-dev-middl…
…eware * 'master' of https://github.com/webpack/webpack-dev-middleware: committed too quickly... Add not-functional test for server side render More tests fix typos Start with some tests! Fix inconsistencies with semi colons Use valid license for npm Document `reporter` option Add changelog for 1.7.0 1.7.0 Removing watching/watching.running check (webpack#100) Improve eslint linting and remove js-beautify Support for server-side rendering (webpack#118)
- Loading branch information
Showing
12 changed files
with
346 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,50 @@ | ||
{ | ||
"env": { | ||
"node": true | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"rules": { | ||
"strict": 0, | ||
"camelcase": 0, | ||
"curly": 0, | ||
"indent": [2, "tab"], | ||
"eol-last": 2, | ||
"no-shadow": 0, | ||
"no-redeclare": 2, | ||
"no-extra-bind": 2, | ||
"no-empty": 0, | ||
"no-process-exit": 2, | ||
"no-underscore-dangle": 0, | ||
"no-use-before-define": 0, | ||
"no-unused-vars": 2, | ||
"consistent-return": 0, | ||
"no-inner-declarations": 2, | ||
"no-loop-func": 2, | ||
"no-undef": 2, | ||
"space-before-function-paren": [2, "never"] | ||
"indent": [2, "tab", { "SwitchCase": 1 }], | ||
"brace-style": ["error", "1tbs"], | ||
"semi": "error", | ||
"no-eval": "error", | ||
"eol-last": "error", | ||
"no-redeclare": "error", | ||
"no-extra-bind": "error", | ||
"no-process-exit": "error", | ||
"no-inner-declarations": "warn", | ||
"no-loop-func": "warn", | ||
"no-undef": "error", | ||
"no-trailing-spaces": "error", | ||
"space-before-function-paren": ["error", "never"], | ||
"no-multi-spaces": "error", | ||
"space-in-parens": "error", | ||
"space-before-blocks": "error", | ||
"no-unused-vars": "error", | ||
"no-dupe-keys": "error", | ||
"valid-typeof": "error", | ||
"space-infix-ops": "error", | ||
"no-negated-in-lhs": "error", | ||
"no-octal": "error", | ||
"no-regex-spaces": "error", | ||
"no-self-assign": "error", | ||
"no-sparse-arrays": "error", | ||
"no-unexpected-multiline": "error", | ||
"no-unreachable": "error", | ||
"no-extra-semi": "error", | ||
"no-func-assign": "error", | ||
"no-invalid-regexp": "error", | ||
"keyword-spacing": ["error", { | ||
"after": false, | ||
"overrides": { | ||
"try": {"after": true}, | ||
"else": {"after": true}, | ||
"throw": {"after": true}, | ||
"case": {"after": true}, | ||
"return": {"after": true}, | ||
"finally": {"after": true}, | ||
"do": {"after": true} | ||
} | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 1.7.0 (2016-09-10) | ||
|
||
- Add `reporter` option for custom logs ([#91](https://github.com/webpack/webpack-dev-middleware/pull/91)). | ||
- Add `serverSideRender` option to help support server-side rendering ([#118](https://github.com/webpack/webpack-dev-middleware/pull/118)). | ||
- Set `statusCode` to 200 for served files ([#94](https://github.com/webpack/webpack-dev-middleware/pull/94)). | ||
- Fix `waitUntilValid` callback always being called immediately when using MultiCompiler ([#100](https://github.com/webpack/webpack-dev-middleware/pull/100)). | ||
- Fix range support not working ([#116](https://github.com/webpack/webpack-dev-middleware/pull/116)). | ||
- Only use middleware for GET requests ([#96](https://github.com/webpack/webpack-dev-middleware/pull/96)). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var pathJoin = require("./PathJoin"); | ||
|
||
function getFilenameFromUrl(publicPath, outputPath, url) { | ||
// publicPrefix is the folder our bundle should be in | ||
var localPrefix = publicPath || "/"; | ||
if(url.indexOf(localPrefix) !== 0) { | ||
if(/^(https?:)?\/\//.test(localPrefix)) { | ||
localPrefix = "/" + localPrefix.replace(/^(https?:)?\/\/[^\/]+\//, ""); | ||
// fast exit if another directory requested | ||
if(url.indexOf(localPrefix) !== 0) return false; | ||
} else return false; | ||
} | ||
// get filename from request | ||
var filename = url.substr(localPrefix.length); | ||
if(filename.indexOf("?") >= 0) { | ||
filename = filename.substr(0, filename.indexOf("?")); | ||
} | ||
return filename ? pathJoin(outputPath, filename) : outputPath; | ||
} | ||
|
||
module.exports = getFilenameFromUrl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function pathJoin(a, b) { | ||
return a == "/" ? "/" + b : (a || "") + "/" + b; | ||
} | ||
|
||
module.exports = pathJoin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
var should = require("should"); | ||
var getFilenameFromUrl = require("../lib/GetFilenameFromUrl"); | ||
|
||
function testUrl(options) { | ||
var url = getFilenameFromUrl(options.publicPath, options.outputPath, options.url); | ||
should.strictEqual(url, options.expected); | ||
} | ||
|
||
describe("GetFilenameFromUrl", function() { | ||
it("should handle urls", function() { | ||
var results = [ | ||
{ | ||
url: "/foo.js", | ||
outputPath: "/", | ||
publicPath: "/", | ||
expected: "/foo.js" | ||
}, { | ||
url: "/0.19dc5d417382d73dd190.hot-update.js", | ||
outputPath: "/", | ||
publicPath: "http://localhost:8080/", | ||
expected: "/0.19dc5d417382d73dd190.hot-update.js" | ||
}, { | ||
url: "/bar.js", | ||
outputPath: "/", | ||
publicPath: "https://localhost:8080/", | ||
expected: "/bar.js" | ||
}, { | ||
url: "/test.html?foo=bar", | ||
outputPath: "/", | ||
publicPath: "/", | ||
expected: "/test.html", | ||
}, { | ||
url: "/a.js", | ||
outputPath: "/dist", | ||
publicPath: "/", | ||
expected: "/dist/a.js", | ||
}, { | ||
url: "/b.js", | ||
outputPath: "/", | ||
publicPath: undefined, | ||
expected: "/b.js", | ||
}, { | ||
url: "/c.js", | ||
outputPath: undefined, | ||
publicPath: undefined, | ||
expected: "/c.js", | ||
}, { | ||
url: "/more/complex/path.js", | ||
outputPath: "/a", | ||
publicPath: "/", | ||
expected: "/a/more/complex/path.js", | ||
}, { | ||
url: "c.js", | ||
outputPath: "/dist", | ||
publicPath: "/", | ||
expected: false, // publicPath is not in url, so it should fail | ||
} | ||
]; | ||
results.forEach(testUrl); | ||
}); | ||
}); |
Oops, something went wrong.