Compare commits
347 Commits
v1.1.5
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b03952404 | ||
|
|
364e273836 | ||
|
|
c4cde95e31 | ||
|
|
b3cf4a76ce | ||
|
|
988bc1109c | ||
|
|
411920523e | ||
|
|
068b999804 | ||
|
|
af5eb8e7c3 | ||
|
|
1696289791 | ||
|
|
d8efc0e652 | ||
|
|
6729afa6d2 | ||
|
|
544279a064 | ||
|
|
7b27f08fac | ||
|
|
d2922cd872 | ||
|
|
51b376a02d | ||
|
|
4e7785c620 | ||
|
|
7bc2da919b | ||
|
|
1e07314bb3 | ||
|
|
b14fff17ff | ||
|
|
b74579da7b | ||
|
|
b827e29cc0 | ||
|
|
783928d36d | ||
|
|
c26a84ccdb | ||
|
|
6410f231d2 | ||
|
|
1230f3a2a4 | ||
|
|
5a6402bc62 | ||
|
|
55c94d53d7 | ||
|
|
85a41c6169 | ||
|
|
c22ac7619b | ||
|
|
410d2e0336 | ||
|
|
395c961e7d | ||
|
|
91a3cd9ac1 | ||
|
|
0812a30474 | ||
|
|
6a3fdb0dae | ||
|
|
8af3044675 | ||
|
|
be96563b6b | ||
|
|
22828c2005 | ||
|
|
9c8d7e70c3 | ||
|
|
ac3c870ad2 | ||
|
|
546b996dad | ||
|
|
de3bcd39c9 | ||
|
|
4bd3a75480 | ||
|
|
0f4a3bd370 | ||
|
|
438feabf50 | ||
|
|
07e47df692 | ||
|
|
81afa23b29 | ||
|
|
cad6e104ef | ||
|
|
947fc1bbc8 | ||
|
|
30ae682927 | ||
|
|
b9469ab500 | ||
|
|
2fb9ab3260 | ||
|
|
9f931d53f9 | ||
|
|
3884c54c00 | ||
|
|
e161893d4a | ||
|
|
006327c26a | ||
|
|
ed99750527 | ||
|
|
5f5124a79a | ||
|
|
b7186ae2db | ||
|
|
6ed2cab63e | ||
|
|
7b37172d09 | ||
|
|
bfef3ecf2a | ||
|
|
4fbef9d380 | ||
|
|
c32caf8a37 | ||
|
|
8e68e57125 | ||
|
|
f3d18ab5ce | ||
|
|
b7b10be97d | ||
|
|
d416ee987e | ||
|
|
f15cbc8386 | ||
|
|
5c959be72f | ||
|
|
a92a2a10d7 | ||
|
|
a4fe4bcf96 | ||
|
|
fe7aa00af8 | ||
|
|
7e737fb9f4 | ||
|
|
ba0c70c6b5 | ||
|
|
ee51d44121 | ||
|
|
313678fdc4 | ||
|
|
4921806568 | ||
|
|
bc57152e09 | ||
|
|
27facca566 | ||
|
|
13f7bc57a2 | ||
|
|
c1db68ba39 | ||
|
|
cb8b5c60f4 | ||
|
|
51372447e0 | ||
|
|
39e8b5782b | ||
|
|
fc7be1bfb5 | ||
|
|
38768868ea | ||
|
|
cd937079b3 | ||
|
|
4f0326af87 | ||
|
|
d0e883a3df | ||
|
|
105ca237f6 | ||
|
|
4d34c9b736 | ||
|
|
34fffcb92c | ||
|
|
86e87f8c5e | ||
|
|
b08cbbabd4 | ||
|
|
34aa14a456 | ||
|
|
9b69727ad2 | ||
|
|
82b74e75bf | ||
|
|
544b6e49a2 | ||
|
|
84660635a2 | ||
|
|
8336655fcb | ||
|
|
6044ccbd7d | ||
|
|
2f549f0bab | ||
|
|
87aa9ef47c | ||
|
|
327056b44b | ||
|
|
6e1bcada54 | ||
|
|
4c64e7b791 | ||
|
|
823d804e58 | ||
|
|
8e1d258ad1 | ||
|
|
c24512e404 | ||
|
|
a15e3fbb0c | ||
|
|
58bfa078c7 | ||
|
|
9f0a8519f5 | ||
|
|
214eea3175 | ||
|
|
018fa454e0 | ||
|
|
4d8b4917e7 | ||
|
|
2b82ea68fc | ||
|
|
3ab32ac667 | ||
|
|
71b655e777 | ||
|
|
2802ec6f2f | ||
|
|
54e0eb7115 | ||
|
|
fc6d3eadac | ||
|
|
e3ff991be9 | ||
|
|
8fbb732bde | ||
|
|
00f3ef67a6 | ||
|
|
5271288d1a | ||
|
|
bda73e36c2 | ||
|
|
9c0287c406 | ||
|
|
136fe69c11 | ||
|
|
0dde93dc69 | ||
|
|
12a56a6f2e | ||
|
|
9569cb6852 | ||
|
|
20e83c893b | ||
|
|
4c8c716ded | ||
|
|
002a251122 | ||
|
|
5583f9ec06 | ||
|
|
4482ec9639 | ||
|
|
e7ae813459 | ||
|
|
fa3fe02a2f | ||
|
|
a30f269f99 | ||
|
|
d8ff9b9e41 | ||
|
|
d3ee7d8f55 | ||
|
|
32b7a1adec | ||
|
|
173f71a6a1 | ||
|
|
4382b8f625 | ||
|
|
6636afe7fd | ||
|
|
156303efe0 | ||
|
|
9c56901718 | ||
|
|
935ee09c82 | ||
|
|
05b0e21848 | ||
|
|
fadb156765 | ||
|
|
abedc7fcfe | ||
|
|
92d67676ff | ||
|
|
fcad6767c0 | ||
|
|
9bf00b76ad | ||
|
|
98107736e0 | ||
|
|
77919cf57b | ||
|
|
010b8c9124 | ||
|
|
b215084582 | ||
|
|
451dc90796 | ||
|
|
9d29665ce3 | ||
|
|
f31db046f6 | ||
|
|
c67b828cbc | ||
|
|
7fc9fe1f7b | ||
|
|
cec35eed49 | ||
|
|
561f159d00 | ||
|
|
d66e8036f7 | ||
|
|
b0f8f33d4a | ||
|
|
a399faa180 | ||
|
|
fc6953383f | ||
|
|
45dbe4f219 | ||
|
|
76e3c3af41 | ||
|
|
da37631e2c | ||
|
|
3e09fb26f9 | ||
|
|
0894f8c9ff | ||
|
|
a4f1ef3d5e | ||
|
|
ccbeaebe69 | ||
|
|
bc077cbe29 | ||
|
|
9ecc9a68f9 | ||
|
|
2b7755a28b | ||
|
|
506626c751 | ||
|
|
2349675b98 | ||
|
|
c5a317fb45 | ||
|
|
9284264604 | ||
|
|
c2585e2c16 | ||
|
|
e7d4062773 | ||
|
|
3e32e4ac3d | ||
|
|
69137b760f | ||
|
|
a8205c834a | ||
|
|
d09bb5e774 | ||
|
|
6024e991ca | ||
|
|
f7e0bb551d | ||
|
|
7215f76cca | ||
|
|
c6b63e4666 | ||
|
|
ec31019c9e | ||
|
|
efe0c6fa7d | ||
|
|
d2bebdbd87 | ||
|
|
3048085dc4 | ||
|
|
1c8c8b9a59 | ||
|
|
2bbaaba5cc | ||
|
|
84285a0826 | ||
|
|
11c2b39640 | ||
|
|
98ecd80f57 | ||
|
|
53a7b06bc6 | ||
|
|
4ed20255be | ||
|
|
8201055cba | ||
|
|
af6bec9cc3 | ||
|
|
2932faa568 | ||
|
|
dc54507b68 | ||
|
|
72b08d6395 | ||
|
|
1284ad0a9f | ||
|
|
a275e385c4 | ||
|
|
357452911d | ||
|
|
fb1c509620 | ||
|
|
2e1836e614 | ||
|
|
ed181e36ed | ||
|
|
f99abfe86a | ||
|
|
e9ccd54a5d | ||
|
|
972e4d1ced | ||
|
|
28e28c8352 | ||
|
|
cd7ab38593 | ||
|
|
a8c6d17b08 | ||
|
|
6cb3ab01a0 | ||
|
|
11b27ed4d3 | ||
|
|
5afc181207 | ||
|
|
8195aa5d6a | ||
|
|
fc9db6b56a | ||
|
|
ac1148a50f | ||
|
|
edc865cb7d | ||
|
|
22e7f31395 | ||
|
|
dd48453baa | ||
|
|
26cc6d91c0 | ||
|
|
735de3e4c0 | ||
|
|
3ce952cfd5 | ||
|
|
7820063014 | ||
|
|
5101c6373c | ||
|
|
b326b6dfa4 | ||
|
|
38a1ab69fa | ||
|
|
191f4b10a3 | ||
|
|
a93f8002a9 | ||
|
|
d3025b9744 | ||
|
|
ac6ea7515a | ||
|
|
b95016be37 | ||
|
|
f39ad778ed | ||
|
|
73413c4caa | ||
|
|
6711bfa431 | ||
|
|
f17363a45d | ||
|
|
db2163892e | ||
|
|
5c74d1e44a | ||
|
|
bd6f5553a5 | ||
|
|
63b45e6208 | ||
|
|
d680e6302d | ||
|
|
420d159be7 | ||
|
|
6d3160a32c | ||
|
|
4056d3375c | ||
|
|
7566e487b0 | ||
|
|
3ae1ea56d3 | ||
|
|
d60c7a0055 | ||
|
|
6781d9536b | ||
|
|
ea919ec568 | ||
|
|
07611f42ad | ||
|
|
e4355f0e97 | ||
|
|
5275b835a7 | ||
|
|
636a8ae7bc | ||
|
|
320226f35a | ||
|
|
2003c3f743 | ||
|
|
e385089155 | ||
|
|
5462db3946 | ||
|
|
cb60444cb1 | ||
|
|
6691f1b75e | ||
|
|
5cb8bcc448 | ||
|
|
e11f253226 | ||
|
|
7381a1d145 | ||
|
|
6a4a87edcd | ||
|
|
99e8ec512a | ||
|
|
197d9f6a0f | ||
|
|
41fe20602a | ||
|
|
b5c886f36d | ||
|
|
6da896f6d8 | ||
|
|
5ec9698c08 | ||
|
|
4da905e4d3 | ||
|
|
62ac6f345b | ||
|
|
9afe1a7816 | ||
|
|
0368c20a58 | ||
|
|
66a13d0814 | ||
|
|
b8d8f4524e | ||
|
|
75efc2d68e | ||
|
|
0bdab07acf | ||
|
|
a6f02f060d | ||
|
|
90252c37b9 | ||
|
|
94fcb7092e | ||
|
|
803e4154b2 | ||
|
|
267913151b | ||
|
|
b1e36ccbf5 | ||
|
|
55e914660b | ||
|
|
0ff43c75a8 | ||
|
|
d15b5f1387 | ||
|
|
d5a4b93449 | ||
|
|
244f8a5541 | ||
|
|
ed11812d3f | ||
|
|
4881fb27da | ||
|
|
07e47b1e78 | ||
|
|
55a5939596 | ||
|
|
12d7cb4a7d | ||
|
|
c602a95d4c | ||
|
|
bf15ad0e12 | ||
|
|
9a77df8c77 | ||
|
|
856450da8f | ||
|
|
1bda9f95e4 | ||
|
|
f0652de409 | ||
|
|
f0579f7093 | ||
|
|
970b567f48 | ||
|
|
47b3884bbe | ||
|
|
5b2ff74554 | ||
|
|
7dc0ff4d97 | ||
|
|
1bdd53c05d | ||
|
|
dce12186f8 | ||
|
|
838ee4cc02 | ||
|
|
f332e6e576 | ||
|
|
b866f9690a | ||
|
|
ac94303941 | ||
|
|
cececc8c2e | ||
|
|
5e050a7d23 | ||
|
|
5731ebee6b | ||
|
|
c6b9d3bdbf | ||
|
|
4686c18e1d | ||
|
|
8a06bb7e19 | ||
|
|
effbe1a4b0 | ||
|
|
351c226736 | ||
|
|
1b098fb723 | ||
|
|
8880a8b80a | ||
|
|
276b52782a | ||
|
|
591fd9ca13 | ||
|
|
857b37aad4 | ||
|
|
40a38e688d | ||
|
|
874d32748b | ||
|
|
63456cccf2 | ||
|
|
6ce2fd216b | ||
|
|
83de752968 | ||
|
|
86db218bdb | ||
|
|
0375dd3638 | ||
|
|
005dbad307 | ||
|
|
a189d6b5e5 | ||
|
|
a01c0286df | ||
|
|
6e4da1e8d6 | ||
|
|
d88117fad9 | ||
|
|
194663a06f | ||
|
|
fd277c695c |
11
.editorconfig
Normal file
11
.editorconfig
Normal file
@@ -0,0 +1,11 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.js,*.json,*.yml}]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
||||
.nyc_output
|
||||
coverage
|
||||
node_modules
|
||||
13
.eslintrc.yml
Normal file
13
.eslintrc.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
root: true
|
||||
extends:
|
||||
- plugin:markdown/recommended
|
||||
plugins:
|
||||
- markdown
|
||||
overrides:
|
||||
- files: '**/*.md'
|
||||
processor: 'markdown/markdown'
|
||||
rules:
|
||||
eol-last: error
|
||||
eqeqeq: [error, allow-null]
|
||||
indent: [error, 2, { SwitchCase: 1 }]
|
||||
no-trailing-spaces: error
|
||||
15
.github/dependabot.yml
vendored
Normal file
15
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
241
.github/workflows/ci.yml
vendored
Normal file
241
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
test:
|
||||
permissions:
|
||||
checks: write # for coverallsapp/github-action to create new checks
|
||||
contents: read # for actions/checkout to fetch code
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
name:
|
||||
- Node.js 0.8
|
||||
- Node.js 0.10
|
||||
- Node.js 0.12
|
||||
- io.js 1.x
|
||||
- io.js 2.x
|
||||
- io.js 3.x
|
||||
- Node.js 4.x
|
||||
- Node.js 5.x
|
||||
- Node.js 6.x
|
||||
- Node.js 7.x
|
||||
- Node.js 8.x
|
||||
- Node.js 9.x
|
||||
- Node.js 10.x
|
||||
- Node.js 11.x
|
||||
- Node.js 12.x
|
||||
- Node.js 13.x
|
||||
- Node.js 14.x
|
||||
- Node.js 15.x
|
||||
- Node.js 16.x
|
||||
- Node.js 17.x
|
||||
- Node.js 18.x
|
||||
- Node.js 19.x
|
||||
- Node.js 20.x
|
||||
- Node.js 21.x
|
||||
- Node.js 22.x
|
||||
- Node.js 23.x
|
||||
- Node.js 24.x
|
||||
|
||||
include:
|
||||
- name: Node.js 0.8
|
||||
node-version: "0.8"
|
||||
npm-i: mocha@2.5.3 supertest@1.1.0
|
||||
npm-rm: nyc
|
||||
|
||||
- name: Node.js 0.10
|
||||
node-version: "0.10"
|
||||
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1
|
||||
|
||||
- name: Node.js 0.12
|
||||
node-version: "0.12"
|
||||
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1
|
||||
|
||||
- name: io.js 1.x
|
||||
node-version: "1"
|
||||
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1
|
||||
|
||||
- name: io.js 2.x
|
||||
node-version: "2"
|
||||
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1
|
||||
|
||||
- name: io.js 3.x
|
||||
node-version: "3"
|
||||
npm-i: mocha@3.5.3 nyc@10.3.2 supertest@2.0.1
|
||||
|
||||
- name: Node.js 4.x
|
||||
node-version: "4"
|
||||
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2
|
||||
|
||||
- name: Node.js 5.x
|
||||
node-version: "5"
|
||||
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2
|
||||
|
||||
- name: Node.js 6.x
|
||||
node-version: "6"
|
||||
npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.3
|
||||
|
||||
- name: Node.js 7.x
|
||||
node-version: "7"
|
||||
npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.3
|
||||
|
||||
- name: Node.js 8.x
|
||||
node-version: "8"
|
||||
npm-i: mocha@7.1.2 nyc@14.1.1 supertest@6.1.3
|
||||
|
||||
- name: Node.js 9.x
|
||||
node-version: "9"
|
||||
npm-i: mocha@7.1.2 nyc@14.1.1 supertest@6.1.3
|
||||
|
||||
- name: Node.js 10.x
|
||||
node-version: "10"
|
||||
npm-i: mocha@8.4.0 supertest@6.1.3
|
||||
|
||||
- name: Node.js 11.x
|
||||
node-version: "11"
|
||||
npm-i: mocha@8.4.0 supertest@6.1.3
|
||||
|
||||
- name: Node.js 12.x
|
||||
node-version: "12"
|
||||
npm-i: mocha@9.2.2 supertest@6.1.3
|
||||
|
||||
- name: Node.js 13.x
|
||||
node-version: "13"
|
||||
npm-i: mocha@9.2.2 supertest@6.1.3
|
||||
|
||||
- name: Node.js 14.x
|
||||
node-version: "14"
|
||||
npm-i: supertest@6.1.3
|
||||
|
||||
- name: Node.js 15.x
|
||||
node-version: "15"
|
||||
npm-i: supertest@6.1.3
|
||||
|
||||
- name: Node.js 16.x
|
||||
node-version: "16"
|
||||
npm-i: supertest@6.1.3
|
||||
|
||||
- name: Node.js 17.x
|
||||
node-version: "17"
|
||||
npm-i: supertest@6.1.3
|
||||
|
||||
- name: Node.js 18.x
|
||||
node-version: "18"
|
||||
|
||||
- name: Node.js 19.x
|
||||
node-version: "19"
|
||||
|
||||
- name: Node.js 20.x
|
||||
node-version: "20"
|
||||
|
||||
- name: Node.js 21.x
|
||||
node-version: "21"
|
||||
|
||||
- name: Node.js 22.x
|
||||
node-version: "22"
|
||||
|
||||
- name: Node.js 23.x
|
||||
node-version: "23"
|
||||
|
||||
- name: Node.js 24.x
|
||||
node-version: "24"
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Install Node.js ${{ matrix.node-version }}
|
||||
shell: bash -eo pipefail -l {0}
|
||||
run: |
|
||||
nvm install --default ${{ matrix.node-version }}
|
||||
if [[ "${{ matrix.node-version }}" == 0.* && "$(cut -d. -f2 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
|
||||
nvm install --alias=npm 0.10
|
||||
nvm use ${{ matrix.node-version }}
|
||||
if [[ "$(npm -v)" == 1.1.* ]]; then
|
||||
nvm exec npm npm install -g npm@1.1
|
||||
ln -fs "$(which npm)" "$(dirname "$(nvm which npm)")/npm"
|
||||
else
|
||||
sed -i '1s;^.*$;'"$(printf '#!%q' "$(nvm which npm)")"';' "$(readlink -f "$(which npm)")"
|
||||
fi
|
||||
npm config set strict-ssl false
|
||||
fi
|
||||
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
|
||||
|
||||
- name: Configure npm
|
||||
run: |
|
||||
if [[ "$(npm config get package-lock)" == "true" ]]; then
|
||||
npm config set package-lock false
|
||||
else
|
||||
npm config set shrinkwrap false
|
||||
fi
|
||||
|
||||
- name: Remove npm module(s) ${{ matrix.npm-rm }}
|
||||
if: matrix.npm-rm != ''
|
||||
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
|
||||
|
||||
- name: Install npm module(s) ${{ matrix.npm-i }}
|
||||
if: matrix.npm-i != ''
|
||||
run: npm install --save-dev ${{ matrix.npm-i }}
|
||||
|
||||
- name: Setup Node.js version-specific dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
# eslint for linting
|
||||
# - remove on Node.js < 12
|
||||
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
|
||||
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
|
||||
grep -E '^eslint(-|$)' | \
|
||||
sort -r | \
|
||||
xargs -n1 npm rm --silent --save-dev
|
||||
fi
|
||||
|
||||
- name: Install Node.js dependencies
|
||||
run: npm install
|
||||
|
||||
- name: List environment
|
||||
id: list_env
|
||||
shell: bash
|
||||
run: |
|
||||
echo "node@$(node -v)"
|
||||
echo "npm@$(npm -v)"
|
||||
npm -s ls ||:
|
||||
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
if npm -ps ls nyc | grep -q nyc; then
|
||||
npm run test-ci
|
||||
else
|
||||
npm test
|
||||
fi
|
||||
|
||||
- name: Lint code
|
||||
if: steps.list_env.outputs.eslint != ''
|
||||
run: npm run lint
|
||||
|
||||
- name: Collect code coverage
|
||||
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # master
|
||||
if: steps.list_env.outputs.nyc != ''
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
flag-name: run-${{ matrix.test_number }}
|
||||
parallel: true
|
||||
|
||||
coverage:
|
||||
permissions:
|
||||
checks: write # for coverallsapp/github-action to create new checks
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Upload code coverage
|
||||
uses: coverallsapp/github-action@648a8eb78e6d50909eff900e4ec85cab4524a45b # master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
parallel-finished: true
|
||||
78
.github/workflows/codeql.yml
vendored
Normal file
78
.github/workflows/codeql.yml
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["master"]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: ["master"]
|
||||
schedule:
|
||||
- cron: "0 0 * * 1"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: ["javascript"]
|
||||
# CodeQL supports [ $supported-codeql-languages ]
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Harden the runner (Audit all outbound calls)
|
||||
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||
|
||||
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
||||
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
||||
|
||||
# - run: |
|
||||
# echo "Run, Build Application using script"
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
|
||||
with:
|
||||
category: "/language:${{matrix.language}}"
|
||||
73
.github/workflows/scorecard.yml
vendored
Normal file
73
.github/workflows/scorecard.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '16 21 * * 1'
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
# Uncomment the permissions below if installing in a private repository.
|
||||
# contents: read
|
||||
# actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@05b42c624433fc40578a4040d5cf5e36ddca8cde # v2.4.2
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecard on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee # v3.29.5
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
.nyc_output/
|
||||
coverage
|
||||
node_modules
|
||||
npm-debug.log
|
||||
package-lock.json
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
coverage
|
||||
test
|
||||
.travis.yml
|
||||
11
.travis.yml
11
.travis.yml
@@ -1,11 +0,0 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
matrix:
|
||||
allow_failures:
|
||||
- node_js: "0.11"
|
||||
fast_finish: true
|
||||
script: "npm run-script test-travis"
|
||||
after_script: "npm install coveralls@2.10.0 && cat ./coverage/lcov.info | coveralls"
|
||||
326
HISTORY.md
Normal file
326
HISTORY.md
Normal file
@@ -0,0 +1,326 @@
|
||||
unreleased
|
||||
==========
|
||||
|
||||
* Fix icons for MIME types with `+`
|
||||
* Fix text and json responses to match html sorting
|
||||
* Show font icon for more font types
|
||||
* Use 400 error on URI decode failure instead of 500
|
||||
* deps: accepts@~1.3.7
|
||||
- deps: mime-types@~2.1.24
|
||||
- deps: negotiator@0.6.2
|
||||
* deps: http-errors@~1.8.0
|
||||
- Set constructor name when possible
|
||||
- deps: depd@~1.1.2
|
||||
- deps: inherits@2.0.4
|
||||
- deps: setprototypeof@1.2.0
|
||||
- deps: statuses@'>= 1.5.0 < 2'
|
||||
* deps: mime-types@~2.1.30
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.47.0
|
||||
* deps: parseurl@~1.3.3
|
||||
|
||||
1.9.1 / 2017-09-28
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.3.4
|
||||
- deps: mime-types@~2.1.16
|
||||
* deps: debug@2.6.9
|
||||
* deps: http-errors@~1.6.2
|
||||
- deps: depd@1.1.1
|
||||
* deps: mime-types@~2.1.17
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.30.0
|
||||
* deps: parseurl@~1.3.2
|
||||
- perf: reduce overhead for full URLs
|
||||
- perf: unroll the "fast-path" `RegExp`
|
||||
|
||||
1.9.0 / 2017-05-25
|
||||
==================
|
||||
|
||||
* Set `X-Content-Type-Options: nosniff` header
|
||||
* deps: batch@0.6.1
|
||||
* deps: debug@2.6.8
|
||||
- Allow colors in workers
|
||||
- Deprecated `DEBUG_FD` environment variable set to `3` or higher
|
||||
- Fix `DEBUG_MAX_ARRAY_LENGTH`
|
||||
- Fix error when running under React Native
|
||||
- Use same color for same namespace
|
||||
- deps: ms@2.0.0
|
||||
* deps: http-errors@~1.6.1
|
||||
- Make `message` property enumerable for `HttpError`s
|
||||
- deps: inherits@2.0.3
|
||||
- deps: setprototypeof@1.0.3
|
||||
- deps: statuses@'>= 1.3.1 < 2'
|
||||
* deps: mime-types@~2.1.15
|
||||
- Add new mime types
|
||||
- Add `audio/mp3`
|
||||
|
||||
1.8.0 / 2016-06-17
|
||||
==================
|
||||
|
||||
* Make inline file search case-insensitive
|
||||
* deps: accepts@~1.3.3
|
||||
- deps: mime-types@~2.1.11
|
||||
- deps: negotiator@0.6.1
|
||||
- perf: improve header parsing speed
|
||||
* deps: http-errors@~1.5.0
|
||||
- Use `setprototypeof` module to replace `__proto__` setting
|
||||
- deps: inherits@2.0.1
|
||||
- deps: statuses@'>= 1.3.0 < 2'
|
||||
- perf: enable strict mode
|
||||
* deps: mime-types@~2.1.11
|
||||
- Add new mime types
|
||||
- Update primary extension for `audio/mp4`
|
||||
- deps: mime-db@~1.23.0
|
||||
|
||||
1.7.3 / 2016-01-24
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.13
|
||||
- deps: mime-types@~2.1.6
|
||||
* deps: batch@0.5.3
|
||||
- Fix invalid dependency for browserify
|
||||
* deps: escape-html@~1.0.3
|
||||
- perf: enable strict mode
|
||||
- perf: optimize string replacement
|
||||
- perf: use faster string coercion
|
||||
* deps: mime-types@~2.1.9
|
||||
- Add new mime types
|
||||
* deps: parseurl@~1.3.1
|
||||
- perf: enable strict mode
|
||||
|
||||
1.7.2 / 2015-07-30
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.12
|
||||
- deps: mime-types@~2.1.4
|
||||
* deps: mime-types@~2.1.4
|
||||
- Add new mime types
|
||||
|
||||
1.7.1 / 2015-07-05
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.10
|
||||
- deps: mime-types@~2.1.2
|
||||
* deps: mime-types@~2.1.2
|
||||
- Add new mime types
|
||||
|
||||
1.7.0 / 2015-06-15
|
||||
==================
|
||||
|
||||
* Accept `function` value for `template` option
|
||||
* Send non-chunked response for `OPTIONS`
|
||||
* Stat parent directory when necessary
|
||||
* Use `Date.prototype.toLocaleDateString` to format date
|
||||
* deps: accepts@~1.2.9
|
||||
- deps: mime-types@~2.1.1
|
||||
- deps: negotiator@0.5.3
|
||||
- perf: avoid argument reassignment & argument slice
|
||||
- perf: avoid negotiator recursive construction
|
||||
- perf: enable strict mode
|
||||
- perf: remove unnecessary bitwise operator
|
||||
* deps: escape-html@1.0.2
|
||||
* deps: mime-types@~2.1.1
|
||||
- Add new mime types
|
||||
* perf: enable strict mode
|
||||
* perf: remove argument reassignment
|
||||
|
||||
1.6.4 / 2015-05-12
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.7
|
||||
- deps: mime-types@~2.0.11
|
||||
- deps: negotiator@0.5.3
|
||||
* deps: debug@~2.2.0
|
||||
- deps: ms@0.7.1
|
||||
* deps: mime-types@~2.0.11
|
||||
- Add new mime types
|
||||
|
||||
1.6.3 / 2015-03-13
|
||||
==================
|
||||
|
||||
* Properly escape file names in HTML
|
||||
* deps: accepts@~1.2.5
|
||||
- deps: mime-types@~2.0.10
|
||||
* deps: debug@~2.1.3
|
||||
- Fix high intensity foreground color for bold
|
||||
- deps: ms@0.7.0
|
||||
* deps: escape-html@1.0.1
|
||||
* deps: mime-types@~2.0.10
|
||||
- Add new mime types
|
||||
|
||||
1.6.2 / 2015-02-16
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.4
|
||||
- deps: mime-types@~2.0.9
|
||||
- deps: negotiator@0.5.1
|
||||
* deps: http-errors@~1.3.1
|
||||
- Construct errors using defined constructors from `createError`
|
||||
- Fix error names that are not identifiers
|
||||
- Set a meaningful `name` property on constructed errors
|
||||
* deps: mime-types@~2.0.9
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.7.0
|
||||
|
||||
1.6.1 / 2015-01-31
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.2.3
|
||||
- deps: mime-types@~2.0.8
|
||||
* deps: mime-types@~2.0.8
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.6.0
|
||||
|
||||
1.6.0 / 2015-01-01
|
||||
==================
|
||||
|
||||
* Add link to root directory
|
||||
* deps: accepts@~1.2.2
|
||||
- deps: mime-types@~2.0.7
|
||||
- deps: negotiator@0.5.0
|
||||
* deps: batch@0.5.2
|
||||
* deps: debug@~2.1.1
|
||||
* deps: mime-types@~2.0.7
|
||||
- Add new mime types
|
||||
- Fix missing extensions
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
- deps: mime-db@~1.5.0
|
||||
|
||||
1.5.3 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.1.4
|
||||
- deps: mime-types@~2.0.4
|
||||
* deps: http-errors@~1.2.8
|
||||
- Fix stack trace from exported function
|
||||
* deps: mime-types@~2.0.4
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.5.2 / 2014-12-03
|
||||
==================
|
||||
|
||||
* Fix icon name background alignment on mobile view
|
||||
|
||||
1.5.1 / 2014-11-22
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.1.3
|
||||
- deps: mime-types@~2.0.3
|
||||
* deps: mime-types@~2.0.3
|
||||
- Add new mime types
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.5.0 / 2014-10-16
|
||||
==================
|
||||
|
||||
* Create errors with `http-errors`
|
||||
* deps: debug@~2.1.0
|
||||
- Implement `DEBUG_FD` env variable support
|
||||
* deps: mime-types@~2.0.2
|
||||
- deps: mime-db@~1.1.0
|
||||
|
||||
1.4.1 / 2014-10-15
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.1.2
|
||||
- Fix error when media type has invalid parameter
|
||||
- deps: negotiator@0.4.9
|
||||
|
||||
1.4.0 / 2014-10-03
|
||||
==================
|
||||
|
||||
* Add `dir` argument to `filter` function
|
||||
* Support using tokens multiple times
|
||||
|
||||
1.3.1 / 2014-10-01
|
||||
==================
|
||||
|
||||
* Fix incorrect 403 on Windows and Node.js 0.11
|
||||
* deps: accepts@~1.1.1
|
||||
- deps: mime-types@~2.0.2
|
||||
- deps: negotiator@0.4.8
|
||||
|
||||
1.3.0 / 2014-09-20
|
||||
==================
|
||||
|
||||
* Add icon for mkv files
|
||||
* Lookup icon by mime type for greater icon support
|
||||
|
||||
1.2.1 / 2014-09-05
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.1.0
|
||||
* deps: debug@~2.0.0
|
||||
|
||||
1.2.0 / 2014-08-25
|
||||
==================
|
||||
|
||||
* Add `debug` messages
|
||||
* Resolve relative paths at middleware setup
|
||||
|
||||
1.1.6 / 2014-08-10
|
||||
==================
|
||||
|
||||
* Fix URL parsing
|
||||
* deps: parseurl@~1.3.0
|
||||
|
||||
1.1.5 / 2014-07-27
|
||||
==================
|
||||
|
||||
* Fix Content-Length calculation for multi-byte file names
|
||||
* deps: accepts@~1.0.7
|
||||
- deps: negotiator@0.4.7
|
||||
|
||||
1.1.4 / 2014-06-20
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.0.5
|
||||
|
||||
1.1.3 / 2014-06-20
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.0.4
|
||||
- use `mime-types`
|
||||
|
||||
1.1.2 / 2014-06-19
|
||||
==================
|
||||
|
||||
* deps: batch@0.5.1
|
||||
|
||||
1.1.1 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: accepts@1.0.3
|
||||
|
||||
1.1.0 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix content negotiation when no `Accept` header
|
||||
* Properly support all HTTP methods
|
||||
* Support vanilla node.js http servers
|
||||
* Treat `ENAMETOOLONG` as code 414
|
||||
* Use accepts for negotiation
|
||||
|
||||
1.0.3 / 2014-05-20
|
||||
==================
|
||||
|
||||
* Fix error from non-statable files in HTML view
|
||||
|
||||
1.0.2 / 2014-04-28
|
||||
==================
|
||||
|
||||
* Add `stylesheet` option
|
||||
* deps: negotiator@0.4.3
|
||||
|
||||
1.0.1 / 2014-03-05
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.2
|
||||
|
||||
1.0.0 / 2014-03-05
|
||||
==================
|
||||
|
||||
* Genesis from connect
|
||||
57
History.md
57
History.md
@@ -1,57 +0,0 @@
|
||||
1.1.5 / 2014-07-27
|
||||
==================
|
||||
|
||||
* Fix Content-Length calculation for multi-byte file names
|
||||
* deps: accepts@~1.0.7
|
||||
- deps: negotiator@0.4.7
|
||||
|
||||
1.1.4 / 2014-06-20
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.0.5
|
||||
|
||||
1.1.3 / 2014-06-20
|
||||
==================
|
||||
|
||||
* deps: accepts@~1.0.4
|
||||
- use `mime-types`
|
||||
|
||||
1.1.2 / 2014-06-19
|
||||
==================
|
||||
|
||||
* deps: batch@0.5.1
|
||||
|
||||
1.1.1 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: accepts@1.0.3
|
||||
|
||||
1.1.0 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix content negotiation when no `Accept` header
|
||||
* Properly support all HTTP methods
|
||||
* Support vanilla node.js http servers
|
||||
* Treat `ENAMETOOLONG` as code 414
|
||||
* Use accepts for negotiation
|
||||
|
||||
1.0.3 / 2014-05-20
|
||||
==================
|
||||
|
||||
* Fix error from non-statable files in HTML view
|
||||
|
||||
1.0.2 / 2014-04-28
|
||||
==================
|
||||
|
||||
* Add `stylesheet` option
|
||||
* deps: negotiator@0.4.3
|
||||
|
||||
1.0.1 / 2014-03-05
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.2
|
||||
|
||||
1.0.0 / 2014-03-05
|
||||
==================
|
||||
|
||||
* Genesis from connect
|
||||
2
LICENSE
2
LICENSE
@@ -3,7 +3,7 @@
|
||||
Copyright (c) 2010 Sencha Inc.
|
||||
Copyright (c) 2011 LearnBoost
|
||||
Copyright (c) 2011 TJ Holowaychuk
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
Copyright (c) 2014-2015 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
||||
151
README.md
Normal file
151
README.md
Normal file
@@ -0,0 +1,151 @@
|
||||
# serve-index
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Linux Build Status][ci-image]][ci-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
Serves pages that contain directory listings for a given path.
|
||||
|
||||
## Install
|
||||
|
||||
This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/). Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```sh
|
||||
$ npm install serve-index
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var serveIndex = require('serve-index')
|
||||
```
|
||||
|
||||
### serveIndex(path, options)
|
||||
|
||||
Returns middlware that serves an index of the directory in the given `path`.
|
||||
|
||||
The `path` is based off the `req.url` value, so a `req.url` of `'/some/dir`
|
||||
with a `path` of `'public'` will look at `'public/some/dir'`. If you are using
|
||||
something like `express`, you can change the URL "base" with `app.use` (see
|
||||
the express example).
|
||||
|
||||
#### Options
|
||||
|
||||
Serve index accepts these properties in the options object.
|
||||
|
||||
##### filter
|
||||
|
||||
Apply this filter function to files. Defaults to `false`. The `filter` function
|
||||
is called for each file, with the signature `filter(filename, index, files, dir)`
|
||||
where `filename` is the name of the file, `index` is the array index, `files` is
|
||||
the array of files and `dir` is the absolute path the file is located (and thus,
|
||||
the directory the listing is for).
|
||||
|
||||
##### hidden
|
||||
|
||||
Display hidden (dot) files. Defaults to `false`.
|
||||
|
||||
##### icons
|
||||
|
||||
Display icons. Defaults to `false`.
|
||||
|
||||
##### stylesheet
|
||||
|
||||
Optional path to a CSS stylesheet. Defaults to a built-in stylesheet.
|
||||
|
||||
##### template
|
||||
|
||||
Optional path to an HTML template or a function that will render a HTML
|
||||
string. Defaults to a built-in template.
|
||||
|
||||
When given a string, the string is used as a file path to load and then the
|
||||
following tokens are replaced in templates:
|
||||
|
||||
* `{directory}` with the name of the directory.
|
||||
* `{files}` with the HTML of an unordered list of file links.
|
||||
* `{linked-path}` with the HTML of a link to the directory.
|
||||
* `{style}` with the specified stylesheet and embedded images.
|
||||
|
||||
When given as a function, the function is called as `template(locals, callback)`
|
||||
and it needs to invoke `callback(error, htmlString)`. The following are the
|
||||
provided locals:
|
||||
|
||||
* `directory` is the directory being displayed (where `/` is the root).
|
||||
* `displayIcons` is a Boolean for if icons should be rendered or not.
|
||||
* `fileList` is a sorted array of files in the directory. The array contains
|
||||
objects with the following properties:
|
||||
- `name` is the relative name for the file.
|
||||
- `stat` is a `fs.Stats` object for the file.
|
||||
* `path` is the full filesystem path to `directory`.
|
||||
* `style` is the default stylesheet or the contents of the `stylesheet` option.
|
||||
* `viewName` is the view name provided by the `view` option.
|
||||
|
||||
##### view
|
||||
|
||||
Display mode. `tiles` and `details` are available. Defaults to `tiles`.
|
||||
|
||||
## Examples
|
||||
|
||||
### Serve directory indexes with vanilla node.js http server
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var http = require('http')
|
||||
var serveIndex = require('serve-index')
|
||||
var serveStatic = require('serve-static')
|
||||
|
||||
// Serve directory indexes for public/ftp folder (with icons)
|
||||
var index = serveIndex('public/ftp', {'icons': true})
|
||||
|
||||
// Serve up public/ftp folder files
|
||||
var serve = serveStatic('public/ftp')
|
||||
|
||||
// Create server
|
||||
var server = http.createServer(function onRequest(req, res){
|
||||
var done = finalhandler(req, res)
|
||||
serve(req, res, function onNext(err) {
|
||||
if (err) return done(err)
|
||||
index(req, res, done)
|
||||
})
|
||||
})
|
||||
|
||||
// Listen
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
### Serve directory indexes with express
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var serveIndex = require('serve-index')
|
||||
|
||||
var app = express()
|
||||
|
||||
// Serve URLs like /ftp/thing as public/ftp/thing
|
||||
// The express.static serves the file contents
|
||||
// The serveIndex is this module serving the directory
|
||||
app.use('/ftp', express.static('public/ftp'), serveIndex('public/ftp', {'icons': true}))
|
||||
|
||||
// Listen
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE). The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons
|
||||
are created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
|
||||
|
||||
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-index/master.svg?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-index
|
||||
[ci-image]: https://badgen.net/github/checks/expressjs/serve-index/master?label=ci
|
||||
[ci-url]: https://github.com/expressjs/serve-index/actions/workflows/ci.yml
|
||||
[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-index/master.svg
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/serve-index?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/serve-index.svg
|
||||
[downloads-url]: https://npmjs.org/package/serve-index
|
||||
[npm-image]: https://img.shields.io/npm/v/serve-index.svg
|
||||
[npm-url]: https://npmjs.org/package/serve-index
|
||||
65
Readme.md
65
Readme.md
@@ -1,65 +0,0 @@
|
||||
# serve-index
|
||||
|
||||
[](http://badge.fury.io/js/serve-index)
|
||||
[](https://travis-ci.org/expressjs/serve-index)
|
||||
[](https://coveralls.io/r/expressjs/serve-index)
|
||||
[](https://www.gittip.com/dougwilson/)
|
||||
|
||||
Serves pages that contain directory listings for a given path.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var serveIndex = require('serve-index')
|
||||
|
||||
var app = express()
|
||||
|
||||
app.use(serveIndex('public/ftp', {'icons': true}))
|
||||
app.listen()
|
||||
```
|
||||
|
||||
### serveIndex(path, options)
|
||||
|
||||
Returns middlware that serves an index of the directory in the given `path`.
|
||||
|
||||
#### Options
|
||||
|
||||
- `hidden` - display hidden (dot) files. Defaults to `false`.
|
||||
- `view` - display mode. `tiles` and `details` are available. Defaults to `tiles`.
|
||||
- `icons` - display icons. Defaults to `false`.
|
||||
- `filter` - Apply this filter function to files. Defaults to `false`.
|
||||
- `stylesheet` - Optional path to a CSS stylesheet. Defaults to a built-in stylesheet.
|
||||
- `template` - Optional path to an HTML template. Defaults to a built-in template.
|
||||
- The following tokens are replaced in templates:
|
||||
- `{directory}` with the name of the directory.
|
||||
- `{files}` with the HTML of an unordered list of file links.
|
||||
- `{linked-path}` with the HTML of a link to the directory.
|
||||
- `{style}` with the specified stylesheet and embedded images.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons are created
|
||||
by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).
|
||||
92
appveyor.yml
Normal file
92
appveyor.yml
Normal file
@@ -0,0 +1,92 @@
|
||||
environment:
|
||||
matrix:
|
||||
- nodejs_version: "0.8"
|
||||
- nodejs_version: "0.10"
|
||||
- nodejs_version: "0.12"
|
||||
- nodejs_version: "1.8"
|
||||
- nodejs_version: "2.5"
|
||||
- nodejs_version: "3.3"
|
||||
- nodejs_version: "4.9"
|
||||
- nodejs_version: "5.12"
|
||||
- nodejs_version: "6.17"
|
||||
- nodejs_version: "7.10"
|
||||
- nodejs_version: "8.17"
|
||||
- nodejs_version: "9.11"
|
||||
- nodejs_version: "10.24"
|
||||
- nodejs_version: "11.15"
|
||||
- nodejs_version: "12.22"
|
||||
- nodejs_version: "13.14"
|
||||
- nodejs_version: "14.16"
|
||||
- nodejs_version: "15.13"
|
||||
cache:
|
||||
- node_modules
|
||||
install:
|
||||
# Install Node.js
|
||||
- ps: >-
|
||||
try { Install-Product node $env:nodejs_version -ErrorAction Stop }
|
||||
catch { Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) }
|
||||
# Configure npm
|
||||
- ps: |
|
||||
# Skip updating shrinkwrap / lock
|
||||
npm config set shrinkwrap false
|
||||
# Skip SSL validation on Node.js < 0.10
|
||||
if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) {
|
||||
npm config set strict-ssl false
|
||||
}
|
||||
# Remove all non-test dependencies
|
||||
- ps: |
|
||||
# Remove coverage dependency
|
||||
npm rm --silent --save-dev nyc
|
||||
# Remove lint dependencies
|
||||
cmd.exe /c "node -pe `"Object.keys(require('./package').devDependencies).join('\n')`"" | `
|
||||
sls "^eslint(-|$)" | `
|
||||
%{ npm rm --silent --save-dev $_ }
|
||||
# Setup Node.js version-specific dependencies
|
||||
- ps: |
|
||||
# mocha for testing
|
||||
# - use 2.x for Node.js < 0.10
|
||||
# - use 3.x for Node.js < 4
|
||||
# - use 5.x for Node.js < 6
|
||||
# - use 6.x for Node.js < 8
|
||||
# - use 7.x for Node.js < 10
|
||||
if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) {
|
||||
npm install --silent --save-dev mocha@2.5.3
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) {
|
||||
npm install --silent --save-dev mocha@3.5.3
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
|
||||
npm install --silent --save-dev mocha@5.2.0
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 8) {
|
||||
npm install --silent --save-dev mocha@6.2.2
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 10) {
|
||||
npm install --silent --save-dev mocha@7.2.0
|
||||
}
|
||||
- ps: |
|
||||
# mocha for testing
|
||||
# - use 1.1.0 for Node.js < 0.10
|
||||
# - use 2.0.0 for Node.js < 4
|
||||
# - use 3.4.2 for Node.js < 6
|
||||
if ([int]$env:nodejs_version.split(".")[0] -eq 0 -and [int]$env:nodejs_version.split(".")[1] -lt 10) {
|
||||
npm install --silent --save-dev supertest@1.1.0
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 4) {
|
||||
npm install --silent --save-dev supertest@2.0.0
|
||||
} elseif ([int]$env:nodejs_version.split(".")[0] -lt 6) {
|
||||
npm install --silent --save-dev supertest@3.4.2
|
||||
}
|
||||
# Update Node.js modules
|
||||
- ps: |
|
||||
# Prune & rebuild node_modules
|
||||
if (Test-Path -Path node_modules) {
|
||||
npm prune
|
||||
npm rebuild
|
||||
}
|
||||
# Install Node.js modules
|
||||
- npm install
|
||||
build: off
|
||||
test_script:
|
||||
# Output version data
|
||||
- ps: |
|
||||
node --version
|
||||
npm --version
|
||||
# Run test script
|
||||
- npm test
|
||||
version: "{build}"
|
||||
711
index.js
711
index.js
@@ -1,29 +1,39 @@
|
||||
|
||||
/*!
|
||||
* serve-index
|
||||
* Copyright(c) 2011 Sencha Inc.
|
||||
* Copyright(c) 2011 TJ Holowaychuk
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* Copyright(c) 2014-2015 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
// TODO: arrow key navigation
|
||||
// TODO: make icons extensible
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var accepts = require('accepts');
|
||||
var http = require('http')
|
||||
, fs = require('fs')
|
||||
, parse = require('url').parse
|
||||
var createError = require('http-errors');
|
||||
var debug = require('debug')('serve-index');
|
||||
var escapeHtml = require('escape-html');
|
||||
var fs = require('fs')
|
||||
, path = require('path')
|
||||
, normalize = path.normalize
|
||||
, sep = path.sep
|
||||
, extname = path.extname
|
||||
, join = path.join;
|
||||
var Batch = require('batch');
|
||||
var mime = require('mime-types');
|
||||
var parseUrl = require('parseurl');
|
||||
var resolve = require('path').resolve;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
* @public
|
||||
*/
|
||||
|
||||
module.exports = serveIndex;
|
||||
|
||||
/*!
|
||||
* Icon cache.
|
||||
@@ -64,50 +74,66 @@ var mediaType = {
|
||||
*
|
||||
* See Readme.md for documentation of options.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {String} root
|
||||
* @param {Object} options
|
||||
* @return {Function} middleware
|
||||
* @api public
|
||||
* @public
|
||||
*/
|
||||
|
||||
exports = module.exports = function serveIndex(root, options){
|
||||
options = options || {};
|
||||
function serveIndex(root, options) {
|
||||
var opts = options || {};
|
||||
|
||||
// root required
|
||||
if (!root) throw new TypeError('serveIndex() root path required');
|
||||
if (!root) {
|
||||
throw new TypeError('serveIndex() root path required');
|
||||
}
|
||||
|
||||
var hidden = options.hidden
|
||||
, icons = options.icons
|
||||
, view = options.view || 'tiles'
|
||||
, filter = options.filter
|
||||
, root = normalize(root + sep)
|
||||
, template = options.template || defaultTemplate
|
||||
, stylesheet = options.stylesheet || defaultStylesheet;
|
||||
// resolve root to absolute and normalize
|
||||
var rootPath = normalize(resolve(root) + sep);
|
||||
|
||||
return function serveIndex(req, res, next) {
|
||||
var filter = opts.filter;
|
||||
var hidden = opts.hidden;
|
||||
var icons = opts.icons;
|
||||
var stylesheet = opts.stylesheet || defaultStylesheet;
|
||||
var template = opts.template || defaultTemplate;
|
||||
var view = opts.view || 'tiles';
|
||||
|
||||
return function (req, res, next) {
|
||||
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
||||
res.statusCode = 'OPTIONS' === req.method
|
||||
? 200
|
||||
: 405;
|
||||
res.statusCode = 'OPTIONS' === req.method ? 200 : 405;
|
||||
res.setHeader('Allow', 'GET, HEAD, OPTIONS');
|
||||
res.setHeader('Content-Length', '0');
|
||||
res.end();
|
||||
return;
|
||||
}
|
||||
|
||||
var url = parse(req.url)
|
||||
, dir = decodeURIComponent(url.pathname)
|
||||
, path = normalize(join(root, dir))
|
||||
, originalUrl = parse(req.originalUrl || req.url)
|
||||
, originalDir = decodeURIComponent(originalUrl.pathname)
|
||||
, showUp = path != root;
|
||||
// get dir
|
||||
var dir = getRequestedDir(req)
|
||||
|
||||
// bad request
|
||||
if (dir === null) return next(createError(400))
|
||||
|
||||
// parse URLs
|
||||
var originalUrl = parseUrl.original(req);
|
||||
var originalDir = decodeURIComponent(originalUrl.pathname);
|
||||
|
||||
// join / normalize from root dir
|
||||
var path = normalize(join(rootPath, dir));
|
||||
|
||||
// null byte(s), bad request
|
||||
if (~path.indexOf('\0')) return next(createError(400));
|
||||
|
||||
// malicious path, forbidden
|
||||
if (0 != path.indexOf(root)) return next(createError(403));
|
||||
// malicious path
|
||||
if ((path + sep).substr(0, rootPath.length) !== rootPath) {
|
||||
debug('malicious path "%s"', path);
|
||||
return next(createError(403));
|
||||
}
|
||||
|
||||
// determine ".." display
|
||||
var showUp = normalize(resolve(path) + sep) !== rootPath;
|
||||
|
||||
// check if we have a directory
|
||||
debug('stat "%s"', path);
|
||||
fs.stat(path, function(err, stat){
|
||||
if (err && err.code === 'ENOENT') {
|
||||
return next();
|
||||
@@ -123,19 +149,22 @@ exports = module.exports = function serveIndex(root, options){
|
||||
if (!stat.isDirectory()) return next();
|
||||
|
||||
// fetch files
|
||||
debug('readdir "%s"', path);
|
||||
fs.readdir(path, function(err, files){
|
||||
if (err) return next(err);
|
||||
if (!hidden) files = removeHidden(files);
|
||||
if (filter) files = files.filter(filter);
|
||||
if (filter) files = files.filter(function(filename, index, list) {
|
||||
return filter(filename, index, list, path);
|
||||
});
|
||||
files.sort();
|
||||
|
||||
// content-negotiation
|
||||
var accept = accepts(req);
|
||||
var type = accept.types(mediaTypes);
|
||||
var type = accept.type(mediaTypes);
|
||||
|
||||
// not acceptable
|
||||
if (!type) return next(createError(406));
|
||||
exports[mediaType[type]](req, res, files, next, originalDir, showUp, icons, path, view, template, stylesheet);
|
||||
serveIndex[mediaType[type]](req, res, files, next, originalDir, showUp, icons, path, view, template, stylesheet);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -145,26 +174,40 @@ exports = module.exports = function serveIndex(root, options){
|
||||
* Respond with text/html.
|
||||
*/
|
||||
|
||||
exports.html = function(req, res, files, next, dir, showUp, icons, path, view, template, stylesheet){
|
||||
fs.readFile(template, 'utf8', function(err, str){
|
||||
if (err) return next(err);
|
||||
fs.readFile(stylesheet, 'utf8', function(err, style){
|
||||
if (err) return next(err);
|
||||
stat(path, files, function(err, stats){
|
||||
if (err) return next(err);
|
||||
files = files.map(function(file, i){ return { name: file, stat: stats[i] }; });
|
||||
files.sort(fileSort);
|
||||
if (showUp) files.unshift({ name: '..' });
|
||||
str = str
|
||||
.replace('{style}', style.concat(iconStyle(files, icons)))
|
||||
.replace('{files}', html(files, dir, icons, view))
|
||||
.replace('{directory}', dir)
|
||||
.replace('{linked-path}', htmlPath(dir));
|
||||
serveIndex.html = function _html(req, res, files, next, dir, showUp, icons, path, view, template, stylesheet) {
|
||||
var render = typeof template !== 'function'
|
||||
? createHtmlRender(template)
|
||||
: template
|
||||
|
||||
var buf = new Buffer(str, 'utf8');
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
||||
res.setHeader('Content-Length', buf.length);
|
||||
res.end(buf);
|
||||
if (showUp) {
|
||||
files.unshift('..');
|
||||
}
|
||||
|
||||
// stat all files
|
||||
stat(path, files, function (err, fileList) {
|
||||
if (err) return next(err);
|
||||
|
||||
// sort file list
|
||||
fileList.sort(fileSort);
|
||||
|
||||
// read stylesheet
|
||||
fs.readFile(stylesheet, 'utf8', function (err, style) {
|
||||
if (err) return next(err);
|
||||
|
||||
// create locals for rendering
|
||||
var locals = {
|
||||
directory: dir,
|
||||
displayIcons: Boolean(icons),
|
||||
fileList: fileList,
|
||||
path: path,
|
||||
style: style,
|
||||
viewName: view
|
||||
};
|
||||
|
||||
// render html
|
||||
render(locals, function (err, body) {
|
||||
if (err) return next(err);
|
||||
send(res, 'text/html', body)
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -174,74 +217,242 @@ exports.html = function(req, res, files, next, dir, showUp, icons, path, view, t
|
||||
* Respond with application/json.
|
||||
*/
|
||||
|
||||
exports.json = function(req, res, files){
|
||||
var body = JSON.stringify(files);
|
||||
var buf = new Buffer(body, 'utf8');
|
||||
serveIndex.json = function _json (req, res, files, next, dir, showUp, icons, path) {
|
||||
// stat all files
|
||||
stat(path, files, function (err, fileList) {
|
||||
if (err) return next(err)
|
||||
|
||||
res.setHeader('Content-Type', 'application/json; charset=utf-8');
|
||||
res.setHeader('Content-Length', buf.length);
|
||||
res.end(buf);
|
||||
// sort file list
|
||||
fileList.sort(fileSort)
|
||||
|
||||
// serialize
|
||||
var body = JSON.stringify(fileList.map(function (file) {
|
||||
return file.name
|
||||
}))
|
||||
|
||||
send(res, 'application/json', body)
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* Respond with text/plain.
|
||||
*/
|
||||
|
||||
exports.plain = function(req, res, files){
|
||||
var body = files.join('\n') + '\n';
|
||||
var buf = new Buffer(body, 'utf8');
|
||||
serveIndex.plain = function _plain (req, res, files, next, dir, showUp, icons, path) {
|
||||
// stat all files
|
||||
stat(path, files, function (err, fileList) {
|
||||
if (err) return next(err)
|
||||
|
||||
res.setHeader('Content-Type', 'text/plain; charset=utf-8');
|
||||
res.setHeader('Content-Length', buf.length);
|
||||
res.end(buf);
|
||||
// sort file list
|
||||
fileList.sort(fileSort)
|
||||
|
||||
// serialize
|
||||
var body = fileList.map(function (file) {
|
||||
return file.name
|
||||
}).join('\n') + '\n'
|
||||
|
||||
send(res, 'text/plain', body)
|
||||
})
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate an `Error` from the given status `code`
|
||||
* and optional `msg`.
|
||||
*
|
||||
* @param {Number} code
|
||||
* @param {String} msg
|
||||
* @return {Error}
|
||||
* @api private
|
||||
* Map html `files`, returning an html unordered list.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function createError(code, msg) {
|
||||
var err = new Error(msg || http.STATUS_CODES[code]);
|
||||
err.status = code;
|
||||
return err;
|
||||
};
|
||||
function createHtmlFileList(files, dir, useIcons, view) {
|
||||
var html = '<ul id="files" class="view-' + escapeHtml(view) + '">'
|
||||
+ (view === 'details' ? (
|
||||
'<li class="header">'
|
||||
+ '<span class="name">Name</span>'
|
||||
+ '<span class="size">Size</span>'
|
||||
+ '<span class="date">Modified</span>'
|
||||
+ '</li>') : '');
|
||||
|
||||
html += files.map(function (file) {
|
||||
var classes = [];
|
||||
var isDir = file.stat && file.stat.isDirectory();
|
||||
var path = dir.split('/').map(function (c) { return encodeURIComponent(c); });
|
||||
|
||||
if (useIcons) {
|
||||
classes.push('icon');
|
||||
|
||||
if (isDir) {
|
||||
classes.push('icon-directory');
|
||||
} else {
|
||||
var ext = extname(file.name);
|
||||
var icon = iconLookup(file.name);
|
||||
|
||||
classes.push('icon');
|
||||
classes.push('icon-' + ext.substring(1));
|
||||
|
||||
if (classes.indexOf(icon.className) === -1) {
|
||||
classes.push(icon.className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
path.push(encodeURIComponent(file.name));
|
||||
|
||||
var date = file.stat && file.name !== '..'
|
||||
? file.stat.mtime.toLocaleDateString() + ' ' + file.stat.mtime.toLocaleTimeString()
|
||||
: '';
|
||||
var size = file.stat && !isDir
|
||||
? file.stat.size
|
||||
: '';
|
||||
|
||||
return '<li><a href="'
|
||||
+ escapeHtml(normalizeSlashes(normalize(path.join('/'))))
|
||||
+ '" class="' + escapeHtml(classes.join(' ')) + '"'
|
||||
+ ' title="' + escapeHtml(file.name) + '">'
|
||||
+ '<span class="name">' + escapeHtml(file.name) + '</span>'
|
||||
+ '<span class="size">' + escapeHtml(size) + '</span>'
|
||||
+ '<span class="date">' + escapeHtml(date) + '</span>'
|
||||
+ '</a></li>';
|
||||
}).join('\n');
|
||||
|
||||
html += '</ul>';
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create function to render html.
|
||||
*/
|
||||
|
||||
function createHtmlRender(template) {
|
||||
return function render(locals, callback) {
|
||||
// read template
|
||||
fs.readFile(template, 'utf8', function (err, str) {
|
||||
if (err) return callback(err);
|
||||
|
||||
var body = str
|
||||
.replace(/\{style\}/g, locals.style.concat(iconStyle(locals.fileList, locals.displayIcons)))
|
||||
.replace(/\{files\}/g, createHtmlFileList(locals.fileList, locals.directory, locals.displayIcons, locals.viewName))
|
||||
.replace(/\{directory\}/g, escapeHtml(locals.directory))
|
||||
.replace(/\{linked-path\}/g, htmlPath(locals.directory));
|
||||
|
||||
callback(null, body);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort function for with directories first.
|
||||
*/
|
||||
|
||||
function fileSort(a, b) {
|
||||
// sort ".." to the top
|
||||
if (a.name === '..' || b.name === '..') {
|
||||
return a.name === b.name ? 0
|
||||
: a.name === '..' ? -1 : 1;
|
||||
}
|
||||
|
||||
return Number(b.stat && b.stat.isDirectory()) - Number(a.stat && a.stat.isDirectory()) ||
|
||||
String(a.name).toLocaleLowerCase().localeCompare(String(b.name).toLocaleLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the requested directory from request.
|
||||
*
|
||||
* @param req
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getRequestedDir (req) {
|
||||
try {
|
||||
return decodeURIComponent(parseUrl(req).pathname)
|
||||
} catch (e) {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map html `dir`, returning a linked path.
|
||||
*/
|
||||
|
||||
function htmlPath(dir) {
|
||||
var curr = [];
|
||||
return dir.split('/').map(function(part){
|
||||
curr.push(encodeURIComponent(part));
|
||||
return part ? '<a href="' + curr.join('/') + '">' + part + '</a>' : '';
|
||||
}).join(' / ');
|
||||
var parts = dir.split('/');
|
||||
var crumb = new Array(parts.length);
|
||||
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
var part = parts[i];
|
||||
|
||||
if (part) {
|
||||
parts[i] = encodeURIComponent(part);
|
||||
crumb[i] = '<a href="' + escapeHtml(parts.slice(0, i + 1).join('/')) + '">' + escapeHtml(part) + '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
return crumb.join(' / ');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the icon data for the file name.
|
||||
*/
|
||||
|
||||
function iconLookup(filename) {
|
||||
var ext = extname(filename);
|
||||
|
||||
// try by extension
|
||||
if (icons[ext]) {
|
||||
return {
|
||||
className: 'icon-' + ext.substring(1),
|
||||
fileName: icons[ext]
|
||||
};
|
||||
}
|
||||
|
||||
var mimetype = mime.lookup(ext);
|
||||
|
||||
// default if no mime type
|
||||
if (mimetype === false) {
|
||||
return {
|
||||
className: 'icon-default',
|
||||
fileName: icons.default
|
||||
};
|
||||
}
|
||||
|
||||
// try by mime type
|
||||
if (icons[mimetype]) {
|
||||
return {
|
||||
className: 'icon-' + mimetype.replace('/', '-').replace('+', '_'),
|
||||
fileName: icons[mimetype]
|
||||
};
|
||||
}
|
||||
|
||||
var suffix = mimetype.split('+')[1];
|
||||
|
||||
if (suffix && icons['+' + suffix]) {
|
||||
return {
|
||||
className: 'icon-' + suffix,
|
||||
fileName: icons['+' + suffix]
|
||||
};
|
||||
}
|
||||
|
||||
var type = mimetype.split('/')[0];
|
||||
|
||||
// try by type only
|
||||
if (icons[type]) {
|
||||
return {
|
||||
className: 'icon-' + type,
|
||||
fileName: icons[type]
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
className: 'icon-default',
|
||||
fileName: icons.default
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Load icon images, return css string.
|
||||
*/
|
||||
|
||||
function iconStyle (files, useIcons) {
|
||||
function iconStyle(files, useIcons) {
|
||||
if (!useIcons) return '';
|
||||
var className;
|
||||
var i;
|
||||
var icon;
|
||||
var list = [];
|
||||
var rules = {};
|
||||
var selector;
|
||||
@@ -251,78 +462,33 @@ function iconStyle (files, useIcons) {
|
||||
for (i = 0; i < files.length; i++) {
|
||||
var file = files[i];
|
||||
|
||||
var isDir = '..' == file.name || (file.stat && file.stat.isDirectory());
|
||||
icon = isDir ? icons.folder : icons[extname(file.name)] || icons.default;
|
||||
var isDir = file.stat && file.stat.isDirectory();
|
||||
var icon = isDir
|
||||
? { className: 'icon-directory', fileName: icons.folder }
|
||||
: iconLookup(file.name);
|
||||
var iconName = icon.fileName;
|
||||
|
||||
var ext = extname(file.name);
|
||||
className = 'icon-' + (isDir ? 'directory' : (icons[ext] ? ext.substring(1) : 'default'));
|
||||
selector = '#files .' + className + ' .name';
|
||||
selector = '#files .' + icon.className + ' .name';
|
||||
|
||||
if (!rules[icon]) {
|
||||
rules[icon] = 'background-image: url(data:image/png;base64,' + load(icon) + ');'
|
||||
selectors[icon] = [];
|
||||
list.push(icon);
|
||||
if (!rules[iconName]) {
|
||||
rules[iconName] = 'background-image: url(data:image/png;base64,' + load(iconName) + ');'
|
||||
selectors[iconName] = [];
|
||||
list.push(iconName);
|
||||
}
|
||||
|
||||
if (!~selectors[icon].indexOf(selector)) {
|
||||
selectors[icon].push(selector);
|
||||
if (selectors[iconName].indexOf(selector) === -1) {
|
||||
selectors[iconName].push(selector);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < list.length; i++) {
|
||||
icon = list[i];
|
||||
style += selectors[icon].join(',\n') + ' {\n ' + rules[icon] + '\n}\n';
|
||||
iconName = list[i];
|
||||
style += selectors[iconName].join(',\n') + ' {\n ' + rules[iconName] + '\n}\n';
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Map html `files`, returning an html unordered list.
|
||||
*/
|
||||
|
||||
function html(files, dir, useIcons, view) {
|
||||
return '<ul id="files" class="view-'+view+'">'
|
||||
+ (view == 'details' ? (
|
||||
'<li class="header">'
|
||||
+ '<span class="name">Name</span>'
|
||||
+ '<span class="size">Size</span>'
|
||||
+ '<span class="date">Modified</span>'
|
||||
+ '</li>') : '')
|
||||
+ files.map(function(file){
|
||||
var isDir = '..' == file.name || (file.stat && file.stat.isDirectory())
|
||||
, classes = []
|
||||
, path = dir.split('/').map(function (c) { return encodeURIComponent(c); });
|
||||
|
||||
if (useIcons) {
|
||||
var ext = extname(file.name);
|
||||
ext = isDir ? '.directory' : (icons[ext] ? ext : '.default');
|
||||
classes.push('icon');
|
||||
classes.push('icon-' + ext.substring(1));
|
||||
}
|
||||
|
||||
path.push(encodeURIComponent(file.name));
|
||||
|
||||
var date = file.stat && file.name !== '..'
|
||||
? file.stat.mtime.toDateString() + ' ' + file.stat.mtime.toLocaleTimeString()
|
||||
: '';
|
||||
var size = file.stat && !isDir
|
||||
? file.stat.size
|
||||
: '';
|
||||
|
||||
return '<li><a href="'
|
||||
+ normalizeSlashes(normalize(path.join('/')))
|
||||
+ '" class="'
|
||||
+ classes.join(' ') + '"'
|
||||
+ ' title="' + file.name + '">'
|
||||
+ '<span class="name">'+file.name+'</span>'
|
||||
+ '<span class="size">'+size+'</span>'
|
||||
+ '<span class="date">'+date+'</span>'
|
||||
+ '</a></li>';
|
||||
|
||||
}).join('\n') + '</ul>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load and cache the given `icon`.
|
||||
*
|
||||
@@ -360,13 +526,34 @@ function normalizeSlashes(path) {
|
||||
|
||||
function removeHidden(files) {
|
||||
return files.filter(function(file){
|
||||
return '.' != file[0];
|
||||
return file[0] !== '.'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat all files and return array of stat
|
||||
* in same order.
|
||||
* Send a response.
|
||||
* @private
|
||||
*/
|
||||
|
||||
function send (res, type, body) {
|
||||
// security header for content sniffing
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff')
|
||||
|
||||
// standard headers
|
||||
res.setHeader('Content-Type', type + '; charset=utf-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'))
|
||||
|
||||
// body
|
||||
res.end(body, 'utf8')
|
||||
}
|
||||
|
||||
/**
|
||||
* Stat all files and return array of objects in the form
|
||||
* `{ name, stat }`.
|
||||
*
|
||||
* @param {Array} files
|
||||
* @return {Array}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stat(dir, files, cb) {
|
||||
@@ -377,12 +564,13 @@ function stat(dir, files, cb) {
|
||||
files.forEach(function(file){
|
||||
batch.push(function(done){
|
||||
fs.stat(join(dir, file), function(err, stat){
|
||||
if (err && err.code !== 'ENOENT') {
|
||||
// pass ENOENT as null stat, not error
|
||||
return done(err);
|
||||
}
|
||||
if (err && err.code !== 'ENOENT') return done(err);
|
||||
|
||||
done(null, stat || null);
|
||||
// pass ENOENT as null stat, not error
|
||||
done(null, {
|
||||
name: file,
|
||||
stat: stat || null
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -395,125 +583,110 @@ function stat(dir, files, cb) {
|
||||
*/
|
||||
|
||||
var icons = {
|
||||
'.js': 'page_white_code_red.png'
|
||||
, '.json': 'page_white_code.png'
|
||||
, '.c': 'page_white_c.png'
|
||||
, '.h': 'page_white_h.png'
|
||||
, '.cc': 'page_white_cplusplus.png'
|
||||
, '.php': 'page_white_php.png'
|
||||
, '.rb': 'page_white_ruby.png'
|
||||
, '.erb': 'page_white_ruby.png'
|
||||
, '.cpp': 'page_white_cplusplus.png'
|
||||
, '.as': 'page_white_actionscript.png'
|
||||
, '.cfm': 'page_white_coldfusion.png'
|
||||
, '.cs': 'page_white_csharp.png'
|
||||
, '.java': 'page_white_cup.png'
|
||||
, '.jsp': 'page_white_cup.png'
|
||||
, '.dll': 'page_white_gear.png'
|
||||
, '.ini': 'page_white_gear.png'
|
||||
, '.asp': 'page_white_code.png'
|
||||
, '.aspx': 'page_white_code.png'
|
||||
, '.clj': 'page_white_code.png'
|
||||
, '.css': 'page_white_code.png'
|
||||
, '.sass': 'page_white_code.png'
|
||||
, '.scss': 'page_white_code.png'
|
||||
, '.less': 'page_white_code.png'
|
||||
, '.htm': 'page_white_code.png'
|
||||
, '.html': 'page_white_code.png'
|
||||
, '.xhtml': 'page_white_code.png'
|
||||
, '.lua': 'page_white_code.png'
|
||||
, '.m': 'page_white_code.png'
|
||||
, '.pl': 'page_white_code.png'
|
||||
, '.py': 'page_white_code.png'
|
||||
, '.vb': 'page_white_code.png'
|
||||
, '.vbs': 'page_white_code.png'
|
||||
, '.xml': 'page_white_code.png'
|
||||
, '.yaws': 'page_white_code.png'
|
||||
, '.map': 'map.png'
|
||||
// base icons
|
||||
'default': 'page_white.png',
|
||||
'folder': 'folder.png',
|
||||
|
||||
, '.app': 'application_xp.png'
|
||||
, '.exe': 'application_xp.png'
|
||||
, '.bat': 'application_xp_terminal.png'
|
||||
, '.cgi': 'application_xp_terminal.png'
|
||||
, '.sh': 'application_xp_terminal.png'
|
||||
// generic mime type icons
|
||||
'font': 'font.png',
|
||||
'image': 'image.png',
|
||||
'text': 'page_white_text.png',
|
||||
'video': 'film.png',
|
||||
|
||||
, '.avi': 'film.png'
|
||||
, '.flv': 'film.png'
|
||||
, '.mv4': 'film.png'
|
||||
, '.mov': 'film.png'
|
||||
, '.mp4': 'film.png'
|
||||
, '.mpeg': 'film.png'
|
||||
, '.mpg': 'film.png'
|
||||
, '.ogv': 'film.png'
|
||||
, '.rm': 'film.png'
|
||||
, '.webm': 'film.png'
|
||||
, '.wmv': 'film.png'
|
||||
, '.fnt': 'font.png'
|
||||
, '.otf': 'font.png'
|
||||
, '.ttf': 'font.png'
|
||||
, '.woff': 'font.png'
|
||||
, '.bmp': 'image.png'
|
||||
, '.gif': 'image.png'
|
||||
, '.ico': 'image.png'
|
||||
, '.jpeg': 'image.png'
|
||||
, '.jpg': 'image.png'
|
||||
, '.png': 'image.png'
|
||||
, '.psd': 'page_white_picture.png'
|
||||
, '.xcf': 'page_white_picture.png'
|
||||
, '.pdf': 'page_white_acrobat.png'
|
||||
, '.swf': 'page_white_flash.png'
|
||||
, '.ai': 'page_white_vector.png'
|
||||
, '.eps': 'page_white_vector.png'
|
||||
, '.ps': 'page_white_vector.png'
|
||||
, '.svg': 'page_white_vector.png'
|
||||
// generic mime suffix icons
|
||||
'+json': 'page_white_code.png',
|
||||
'+xml': 'page_white_code.png',
|
||||
'+zip': 'box.png',
|
||||
|
||||
, '.ods': 'page_white_excel.png'
|
||||
, '.xls': 'page_white_excel.png'
|
||||
, '.xlsx': 'page_white_excel.png'
|
||||
, '.odp': 'page_white_powerpoint.png'
|
||||
, '.ppt': 'page_white_powerpoint.png'
|
||||
, '.pptx': 'page_white_powerpoint.png'
|
||||
, '.md': 'page_white_text.png'
|
||||
, '.srt': 'page_white_text.png'
|
||||
, '.txt': 'page_white_text.png'
|
||||
, '.doc': 'page_white_word.png'
|
||||
, '.docx': 'page_white_word.png'
|
||||
, '.odt': 'page_white_word.png'
|
||||
, '.rtf': 'page_white_word.png'
|
||||
// specific mime type icons
|
||||
'application/javascript': 'page_white_code_red.png',
|
||||
'application/json': 'page_white_code.png',
|
||||
'application/msword': 'page_white_word.png',
|
||||
'application/pdf': 'page_white_acrobat.png',
|
||||
'application/postscript': 'page_white_vector.png',
|
||||
'application/rtf': 'page_white_word.png',
|
||||
'application/vnd.ms-excel': 'page_white_excel.png',
|
||||
'application/vnd.ms-powerpoint': 'page_white_powerpoint.png',
|
||||
'application/vnd.oasis.opendocument.presentation': 'page_white_powerpoint.png',
|
||||
'application/vnd.oasis.opendocument.spreadsheet': 'page_white_excel.png',
|
||||
'application/vnd.oasis.opendocument.text': 'page_white_word.png',
|
||||
'application/x-7z-compressed': 'box.png',
|
||||
'application/x-sh': 'application_xp_terminal.png',
|
||||
'application/x-msaccess': 'page_white_database.png',
|
||||
'application/x-shockwave-flash': 'page_white_flash.png',
|
||||
'application/x-sql': 'page_white_database.png',
|
||||
'application/x-tar': 'box.png',
|
||||
'application/x-xz': 'box.png',
|
||||
'application/xml': 'page_white_code.png',
|
||||
'application/zip': 'box.png',
|
||||
'image/svg+xml': 'page_white_vector.png',
|
||||
'text/css': 'page_white_code.png',
|
||||
'text/html': 'page_white_code.png',
|
||||
'text/less': 'page_white_code.png',
|
||||
|
||||
, '.dmg': 'drive.png'
|
||||
, '.iso': 'cd.png'
|
||||
, '.7z': 'box.png'
|
||||
, '.apk': 'box.png'
|
||||
, '.bz2': 'box.png'
|
||||
, '.cab': 'box.png'
|
||||
, '.deb': 'box.png'
|
||||
, '.gz': 'box.png'
|
||||
, '.jar': 'box.png'
|
||||
, '.lz': 'box.png'
|
||||
, '.lzma': 'box.png'
|
||||
, '.msi': 'box.png'
|
||||
, '.pkg': 'box.png'
|
||||
, '.rar': 'box.png'
|
||||
, '.rpm': 'box.png'
|
||||
, '.tar': 'box.png'
|
||||
, '.tbz2': 'box.png'
|
||||
, '.tgz': 'box.png'
|
||||
, '.tlz': 'box.png'
|
||||
, '.xz': 'box.png'
|
||||
, '.zip': 'box.png'
|
||||
|
||||
, '.accdb': 'page_white_database.png'
|
||||
, '.db': 'page_white_database.png'
|
||||
, '.dbf': 'page_white_database.png'
|
||||
, '.mdb': 'page_white_database.png'
|
||||
, '.pdb': 'page_white_database.png'
|
||||
, '.sql': 'page_white_database.png'
|
||||
|
||||
, '.gam': 'controller.png'
|
||||
, '.rom': 'controller.png'
|
||||
, '.sav': 'controller.png'
|
||||
|
||||
, 'folder': 'folder.png'
|
||||
, 'default': 'page_white.png'
|
||||
// other, extension-specific icons
|
||||
'.accdb': 'page_white_database.png',
|
||||
'.apk': 'box.png',
|
||||
'.app': 'application_xp.png',
|
||||
'.as': 'page_white_actionscript.png',
|
||||
'.asp': 'page_white_code.png',
|
||||
'.aspx': 'page_white_code.png',
|
||||
'.bat': 'application_xp_terminal.png',
|
||||
'.bz2': 'box.png',
|
||||
'.c': 'page_white_c.png',
|
||||
'.cab': 'box.png',
|
||||
'.cfm': 'page_white_coldfusion.png',
|
||||
'.clj': 'page_white_code.png',
|
||||
'.cc': 'page_white_cplusplus.png',
|
||||
'.cgi': 'application_xp_terminal.png',
|
||||
'.cpp': 'page_white_cplusplus.png',
|
||||
'.cs': 'page_white_csharp.png',
|
||||
'.db': 'page_white_database.png',
|
||||
'.dbf': 'page_white_database.png',
|
||||
'.deb': 'box.png',
|
||||
'.dll': 'page_white_gear.png',
|
||||
'.dmg': 'drive.png',
|
||||
'.docx': 'page_white_word.png',
|
||||
'.erb': 'page_white_ruby.png',
|
||||
'.exe': 'application_xp.png',
|
||||
'.fnt': 'font.png',
|
||||
'.gam': 'controller.png',
|
||||
'.gz': 'box.png',
|
||||
'.h': 'page_white_h.png',
|
||||
'.ini': 'page_white_gear.png',
|
||||
'.iso': 'cd.png',
|
||||
'.jar': 'box.png',
|
||||
'.java': 'page_white_cup.png',
|
||||
'.jsp': 'page_white_cup.png',
|
||||
'.lua': 'page_white_code.png',
|
||||
'.lz': 'box.png',
|
||||
'.lzma': 'box.png',
|
||||
'.m': 'page_white_code.png',
|
||||
'.map': 'map.png',
|
||||
'.msi': 'box.png',
|
||||
'.mv4': 'film.png',
|
||||
'.pdb': 'page_white_database.png',
|
||||
'.php': 'page_white_php.png',
|
||||
'.pl': 'page_white_code.png',
|
||||
'.pkg': 'box.png',
|
||||
'.pptx': 'page_white_powerpoint.png',
|
||||
'.psd': 'page_white_picture.png',
|
||||
'.py': 'page_white_code.png',
|
||||
'.rar': 'box.png',
|
||||
'.rb': 'page_white_ruby.png',
|
||||
'.rm': 'film.png',
|
||||
'.rom': 'controller.png',
|
||||
'.rpm': 'box.png',
|
||||
'.sass': 'page_white_code.png',
|
||||
'.sav': 'controller.png',
|
||||
'.scss': 'page_white_code.png',
|
||||
'.srt': 'page_white_text.png',
|
||||
'.tbz2': 'box.png',
|
||||
'.tgz': 'box.png',
|
||||
'.tlz': 'box.png',
|
||||
'.vb': 'page_white_code.png',
|
||||
'.vbs': 'page_white_code.png',
|
||||
'.xcf': 'page_white_picture.png',
|
||||
'.xlsx': 'page_white_excel.png',
|
||||
'.yaws': 'page_white_code.png'
|
||||
};
|
||||
|
||||
38
package.json
38
package.json
@@ -1,26 +1,44 @@
|
||||
{
|
||||
"name": "serve-index",
|
||||
"description": "Serve directory listings",
|
||||
"version": "1.1.5",
|
||||
"version": "1.9.1",
|
||||
"author": "Douglas Christopher Wilson <doug@somethingdoug.com>",
|
||||
"license": "MIT",
|
||||
"repository": "expressjs/serve-index",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
},
|
||||
"dependencies": {
|
||||
"accepts": "~1.0.7",
|
||||
"batch": "0.5.1"
|
||||
"accepts": "~1.3.7",
|
||||
"batch": "0.6.1",
|
||||
"debug": "2.6.9",
|
||||
"escape-html": "~1.0.3",
|
||||
"http-errors": "~1.8.0",
|
||||
"mime-types": "~2.1.29",
|
||||
"parseurl": "~1.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.0",
|
||||
"mocha": "~1.21.1",
|
||||
"should": "~4.0.0",
|
||||
"supertest": "~0.13.0"
|
||||
"after": "0.8.2",
|
||||
"eslint": "7.23.0",
|
||||
"eslint-plugin-markdown": "2.0.0",
|
||||
"mocha": "10.4.0",
|
||||
"nyc": "15.1.0",
|
||||
"supertest": "7.0.0"
|
||||
},
|
||||
"files": [
|
||||
"public/",
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter dot",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec"
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --reporter spec --bail --check-leaks test/",
|
||||
"test-ci": "nyc --reporter=lcov --reporter=text npm test",
|
||||
"test-cov": "nyc --reporter=html --reporter=text npm test"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@
|
||||
}
|
||||
|
||||
function search() {
|
||||
var str = $('search').value
|
||||
, links = $('files').all('a');
|
||||
var str = $('search').value.toLowerCase();
|
||||
var links = $('files').all('a');
|
||||
|
||||
links.each(function(link){
|
||||
var text = link.textContent;
|
||||
var text = link.textContent.toLowerCase();
|
||||
|
||||
if ('..' == text) return;
|
||||
if (str.length && ~text.indexOf(str)) {
|
||||
@@ -75,7 +75,7 @@
|
||||
<body class="directory">
|
||||
<input id="search" type="text" placeholder="Search" autocomplete="off" />
|
||||
<div id="wrapper">
|
||||
<h1>{linked-path}</h1>
|
||||
<h1><a href="/">~</a>{linked-path}</h1>
|
||||
{files}
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -249,7 +249,7 @@ ul#files.view-details li.header {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
text-indent: 0;
|
||||
background-position: 0 0;
|
||||
background-position: 0 50%;
|
||||
}
|
||||
#files .icon .name {
|
||||
text-indent: 41px;
|
||||
|
||||
0
test/fixtures/collect/sample.jpg
vendored
Normal file
0
test/fixtures/collect/sample.jpg
vendored
Normal file
0
test/fixtures/collect/sample.mp4
vendored
Normal file
0
test/fixtures/collect/sample.mp4
vendored
Normal file
0
test/fixtures/collect/sample.pdf
vendored
Normal file
0
test/fixtures/collect/sample.pdf
vendored
Normal file
0
test/fixtures/collect/sample.qfx
vendored
Normal file
0
test/fixtures/collect/sample.qfx
vendored
Normal file
0
test/fixtures/collect/sample.rdf
vendored
Normal file
0
test/fixtures/collect/sample.rdf
vendored
Normal file
0
test/fixtures/collect/sample.svg
vendored
Normal file
0
test/fixtures/collect/sample.svg
vendored
Normal file
0
test/fixtures/collect/sample.txt
vendored
Normal file
0
test/fixtures/collect/sample.txt
vendored
Normal file
0
test/fixtures/collect/sample.xlsx
vendored
Normal file
0
test/fixtures/collect/sample.xlsx
vendored
Normal file
0
test/fixtures/g# %3 o & %2525 %37 dir/empty.txt
vendored
Normal file
0
test/fixtures/g# %3 o & %2525 %37 dir/empty.txt
vendored
Normal file
1
test/fixtures/users/#dir/tobi.txt
vendored
Normal file
1
test/fixtures/users/#dir/tobi.txt
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ferret
|
||||
@@ -1,26 +0,0 @@
|
||||
|
||||
var bytes = require('bytes');
|
||||
|
||||
exports['default request body'] = function(app){
|
||||
it('should default to {}', function(done){
|
||||
app.request()
|
||||
.post('/')
|
||||
.end(function(res){
|
||||
res.body.should.equal('{}');
|
||||
done();
|
||||
})
|
||||
})
|
||||
};
|
||||
|
||||
exports['limit body to'] = function(size, type, app){
|
||||
it('should accept a limit option', function(done){
|
||||
app.request()
|
||||
.post('/')
|
||||
.set('Content-Length', bytes(size) + 1)
|
||||
.set('Content-Type', type)
|
||||
.end(function(res){
|
||||
res.should.have.status(413);
|
||||
done();
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
</head>
|
||||
<body class="directory">
|
||||
<h1>This is the test template</h1>
|
||||
<h2>directory {directory}</h2>
|
||||
<div id="wrapper">
|
||||
<h1>{linked-path}</h1>
|
||||
{files}
|
||||
|
||||
765
test/test.js
765
test/test.js
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user