woodland 18.2.7 → 18.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
6
6
  * @license BSD-3-Clause
7
- * @version 18.2.7
7
+ * @version 18.2.8
8
8
  */
9
9
  'use strict';
10
10
 
package/dist/woodland.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
5
5
  * @license BSD-3-Clause
6
- * @version 18.2.7
6
+ * @version 18.2.8
7
7
  */
8
8
  'use strict';
9
9
 
@@ -796,8 +796,8 @@ class Woodland extends node_events.EventEmitter {
796
796
  };
797
797
  }
798
798
 
799
- async serve (req, res, arg = EMPTY, folder = process.cwd(), index = this.indexes) {
800
- const fp = node_path.resolve(folder, decodeURIComponent(arg));
799
+ async serve (req, res, arg, folder = process.cwd()) {
800
+ const fp = node_path.join(folder, arg);
801
801
 
802
802
  if (req.method !== GET && req.method !== HEAD && req.method !== OPTIONS) {
803
803
  if (req.allow.length > INT_0) {
@@ -833,7 +833,7 @@ class Woodland extends node_events.EventEmitter {
833
833
  let result = EMPTY;
834
834
 
835
835
  for (const file of files) {
836
- if (index.includes(file.name)) {
836
+ if (this.indexes.includes(file.name)) {
837
837
  result = node_path.join(fp, file.name);
838
838
  break;
839
839
  }
@@ -874,9 +874,8 @@ class Woodland extends node_events.EventEmitter {
874
874
  };
875
875
  }
876
876
 
877
- staticFiles (root = SLASH) {
878
- /* istanbul ignore next */
879
- this.get(`${root}(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1)));
877
+ staticFiles (root, folder = process.cwd()) {
878
+ this.get(`${root.replace(/\/$/, EMPTY)}/(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1), folder));
880
879
  }
881
880
 
882
881
  trace (...args) {
package/dist/woodland.js CHANGED
@@ -3,9 +3,9 @@
3
3
  *
4
4
  * @copyright 2024 Jason Mulligan <jason.mulligan@avoidwork.com>
5
5
  * @license BSD-3-Clause
6
- * @version 18.2.7
6
+ * @version 18.2.8
7
7
  */
8
- import {STATUS_CODES,METHODS}from'node:http';import {join,extname,resolve}from'node:path';import {EventEmitter}from'node:events';import {stat,readdir}from'node:fs/promises';import {etag}from'tiny-etag';import {precise}from'precise';import {lru}from'tiny-lru';import {createRequire}from'node:module';import {fileURLToPath,URL}from'node:url';import {readFileSync,createReadStream}from'node:fs';import {coerce}from'tiny-coerce';import mimeDb from'mime-db';const __dirname$1 = fileURLToPath(new URL(".", import.meta.url));
8
+ import {STATUS_CODES,METHODS}from'node:http';import {join,extname}from'node:path';import {EventEmitter}from'node:events';import {stat,readdir}from'node:fs/promises';import {etag}from'tiny-etag';import {precise}from'precise';import {lru}from'tiny-lru';import {createRequire}from'node:module';import {fileURLToPath,URL}from'node:url';import {readFileSync,createReadStream}from'node:fs';import {coerce}from'tiny-coerce';import mimeDb from'mime-db';const __dirname$1 = fileURLToPath(new URL(".", import.meta.url));
9
9
  const require = createRequire(import.meta.url);
10
10
  const {name, version} = require(join(__dirname$1, "..", "package.json"));
11
11
 
@@ -776,8 +776,8 @@ function writeHead (res, headers = {}) {
776
776
  };
777
777
  }
778
778
 
779
- async serve (req, res, arg = EMPTY, folder = process.cwd(), index = this.indexes) {
780
- const fp = resolve(folder, decodeURIComponent(arg));
779
+ async serve (req, res, arg, folder = process.cwd()) {
780
+ const fp = join(folder, arg);
781
781
 
782
782
  if (req.method !== GET && req.method !== HEAD && req.method !== OPTIONS) {
783
783
  if (req.allow.length > INT_0) {
@@ -813,7 +813,7 @@ function writeHead (res, headers = {}) {
813
813
  let result = EMPTY;
814
814
 
815
815
  for (const file of files) {
816
- if (index.includes(file.name)) {
816
+ if (this.indexes.includes(file.name)) {
817
817
  result = join(fp, file.name);
818
818
  break;
819
819
  }
@@ -854,9 +854,8 @@ function writeHead (res, headers = {}) {
854
854
  };
855
855
  }
856
856
 
857
- staticFiles (root = SLASH) {
858
- /* istanbul ignore next */
859
- this.get(`${root}(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1)));
857
+ staticFiles (root, folder = process.cwd()) {
858
+ this.get(`${root.replace(/\/$/, EMPTY)}/(.*)?`, (req, res) => this.serve(req, res, req.parsed.pathname.substring(1), folder));
860
859
  }
861
860
 
862
861
  trace (...args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "woodland",
3
- "version": "18.2.7",
3
+ "version": "18.2.8",
4
4
  "description": "Lightweight HTTP framework with automatic headers",
5
5
  "type": "module",
6
6
  "types": "types/woodland.d.ts",