-
-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0f2b227
commit 3a854ba
Showing
26 changed files
with
1,345 additions
and
897 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,23 +1,16 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = tab | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
max_line_length = 233 | ||
|
||
[*.json] | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.yml] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[test/cases/parsing/bom/bomfile.{css,js}] | ||
charset = utf-8-bom | ||
|
||
[*.md] | ||
insert_final_newline = true | ||
trim_trailing_whitespace = false |
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,58 +1,35 @@ | ||
{ | ||
"root": true, | ||
"plugins": ["node"], | ||
"extends": ["eslint:recommended", "plugin:node/recommended"], | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
"quotes": ["error", "double"], | ||
"no-undef": "error", | ||
"no-extra-semi": "error", | ||
"semi": "error", | ||
"no-template-curly-in-string": "error", | ||
"no-caller": "error", | ||
"yoda": "error", | ||
"eqeqeq": "error", | ||
"global-require": "off", | ||
"brace-style": "error", | ||
"eol-last": "error", | ||
"indent": ["error", "tab", { "SwitchCase": 1 }], | ||
"no-extra-bind": "warn", | ||
"no-empty": "off", | ||
"no-multiple-empty-lines": "error", | ||
"no-multi-spaces": "error", | ||
"no-process-exit": "warn", | ||
"space-in-parens": "error", | ||
"no-trailing-spaces": "error", | ||
"no-use-before-define": "off", | ||
"no-unused-vars": ["error", {"args": "none"}], | ||
"key-spacing": "error", | ||
"space-infix-ops": "error", | ||
"no-unsafe-negation": "error", | ||
"no-loop-func": "warn", | ||
"space-before-function-paren": ["error", "never"], | ||
"space-before-blocks": "error", | ||
"object-curly-spacing": ["error", "always"], | ||
"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} | ||
} | ||
}], | ||
"no-console": "off", | ||
"valid-jsdoc": "error", | ||
"no-var": "error", | ||
"prefer-const": "error", | ||
"prefer-arrow-callback": "error", | ||
"root": true, | ||
"plugins": ["node", "prettier"], | ||
"extends": ["eslint:recommended", "plugin:node/recommended"], | ||
"env": { | ||
"node": true | ||
}, | ||
"rules": { | ||
"no-template-curly-in-string": "error", | ||
"no-caller": "error", | ||
"yoda": "error", | ||
"eqeqeq": "error", | ||
"no-extra-bind": "error", | ||
"no-process-exit": "error", | ||
"no-loop-func": "error", | ||
"no-console": "off", | ||
"valid-jsdoc": "error", | ||
"no-var": "error", | ||
"prefer-const": "error", | ||
"prefer-arrow-callback": "error", | ||
"object-shorthand": "error", | ||
|
||
// Allow to use `assert` module | ||
"node/no-deprecated-api": "off" | ||
} | ||
"node/no-deprecated-api": "off", | ||
|
||
"prettier/prettier": [ | ||
"error", | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"arrowParens": "always" | ||
} | ||
] | ||
} | ||
} |
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 @@ | ||
{ | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"arrowParens": "always" | ||
} |
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 |
---|---|---|
@@ -1,13 +1,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
function getCurrentRequest(loaderContext) { | ||
if(loaderContext.currentRequest) | ||
return loaderContext.currentRequest; | ||
const request = loaderContext.loaders | ||
.slice(loaderContext.loaderIndex) | ||
.map(obj => obj.request) | ||
.concat([loaderContext.resource]); | ||
return request.join("!"); | ||
if (loaderContext.currentRequest) { | ||
return loaderContext.currentRequest; | ||
} | ||
|
||
const request = loaderContext.loaders | ||
.slice(loaderContext.loaderIndex) | ||
.map((obj) => obj.request) | ||
.concat([loaderContext.resource]); | ||
|
||
return request.join('!'); | ||
} | ||
|
||
module.exports = getCurrentRequest; |
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,53 +1,69 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
const baseEncodeTables = { | ||
26: "abcdefghijklmnopqrstuvwxyz", | ||
32: "123456789abcdefghjkmnpqrstuvwxyz", // no 0lio | ||
36: "0123456789abcdefghijklmnopqrstuvwxyz", | ||
49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no lIO | ||
52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", | ||
58: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ", // no 0lIO | ||
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", | ||
64: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_" | ||
26: 'abcdefghijklmnopqrstuvwxyz', | ||
32: '123456789abcdefghjkmnpqrstuvwxyz', // no 0lio | ||
36: '0123456789abcdefghijklmnopqrstuvwxyz', | ||
49: 'abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no lIO | ||
52: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
58: '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ', // no 0lIO | ||
62: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', | ||
64: '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_', | ||
}; | ||
|
||
function encodeBufferToBase(buffer, base) { | ||
const encodeTable = baseEncodeTables[base]; | ||
if(!encodeTable) throw new Error("Unknown encoding base" + base); | ||
const encodeTable = baseEncodeTables[base]; | ||
if (!encodeTable) { | ||
throw new Error('Unknown encoding base' + base); | ||
} | ||
|
||
const readLength = buffer.length; | ||
const readLength = buffer.length; | ||
const Big = require('big.js'); | ||
|
||
const Big = require("big.js"); | ||
Big.RM = Big.DP = 0; | ||
let b = new Big(0); | ||
for(let i = readLength - 1; i >= 0; i--) { | ||
b = b.times(256).plus(buffer[i]); | ||
} | ||
Big.RM = Big.DP = 0; | ||
let b = new Big(0); | ||
|
||
let output = ""; | ||
while(b.gt(0)) { | ||
output = encodeTable[b.mod(base)] + output; | ||
b = b.div(base); | ||
} | ||
for (let i = readLength - 1; i >= 0; i--) { | ||
b = b.times(256).plus(buffer[i]); | ||
} | ||
|
||
Big.DP = 20; | ||
Big.RM = 1; | ||
let output = ''; | ||
while (b.gt(0)) { | ||
output = encodeTable[b.mod(base)] + output; | ||
b = b.div(base); | ||
} | ||
|
||
return output; | ||
Big.DP = 20; | ||
Big.RM = 1; | ||
|
||
return output; | ||
} | ||
|
||
function getHashDigest(buffer, hashType, digestType, maxLength) { | ||
hashType = hashType || "md5"; | ||
maxLength = maxLength || 9999; | ||
const hash = require("crypto").createHash(hashType); | ||
hash.update(buffer); | ||
if(digestType === "base26" || digestType === "base32" || digestType === "base36" || | ||
digestType === "base49" || digestType === "base52" || digestType === "base58" || | ||
digestType === "base62" || digestType === "base64") { | ||
return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr(0, maxLength); | ||
} else { | ||
return hash.digest(digestType || "hex").substr(0, maxLength); | ||
} | ||
hashType = hashType || 'md5'; | ||
maxLength = maxLength || 9999; | ||
|
||
const hash = require('crypto').createHash(hashType); | ||
|
||
hash.update(buffer); | ||
|
||
if ( | ||
digestType === 'base26' || | ||
digestType === 'base32' || | ||
digestType === 'base36' || | ||
digestType === 'base49' || | ||
digestType === 'base52' || | ||
digestType === 'base58' || | ||
digestType === 'base62' || | ||
digestType === 'base64' | ||
) { | ||
return encodeBufferToBase(hash.digest(), digestType.substr(4)).substr( | ||
0, | ||
maxLength | ||
); | ||
} else { | ||
return hash.digest(digestType || 'hex').substr(0, maxLength); | ||
} | ||
} | ||
|
||
module.exports = getHashDigest; |
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,17 +1,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
const parseQuery = require("./parseQuery"); | ||
const parseQuery = require('./parseQuery'); | ||
|
||
function getOptions(loaderContext) { | ||
const query = loaderContext.query; | ||
if(typeof query === "string" && query !== "") { | ||
return parseQuery(loaderContext.query); | ||
} | ||
if(!query || typeof query !== "object") { | ||
// Not object-like queries are not supported. | ||
return null; | ||
} | ||
return query; | ||
const query = loaderContext.query; | ||
|
||
if (typeof query === 'string' && query !== '') { | ||
return parseQuery(loaderContext.query); | ||
} | ||
|
||
if (!query || typeof query !== 'object') { | ||
// Not object-like queries are not supported. | ||
return null; | ||
} | ||
|
||
return query; | ||
} | ||
|
||
module.exports = getOptions; |
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,13 +1,16 @@ | ||
"use strict"; | ||
'use strict'; | ||
|
||
function getRemainingRequest(loaderContext) { | ||
if(loaderContext.remainingRequest) | ||
return loaderContext.remainingRequest; | ||
const request = loaderContext.loaders | ||
.slice(loaderContext.loaderIndex + 1) | ||
.map(obj => obj.request) | ||
.concat([loaderContext.resource]); | ||
return request.join("!"); | ||
if (loaderContext.remainingRequest) { | ||
return loaderContext.remainingRequest; | ||
} | ||
|
||
const request = loaderContext.loaders | ||
.slice(loaderContext.loaderIndex + 1) | ||
.map((obj) => obj.request) | ||
.concat([loaderContext.resource]); | ||
|
||
return request.join('!'); | ||
} | ||
|
||
module.exports = getRemainingRequest; |
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
Oops, something went wrong.