@ultimat3/http 4.0.0 → 4.1.0

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.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/src/error-map.ts +9 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/http",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Owned request lifecycle over Bun.serve: router, ordered pipeline, problem+json errors",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -31,9 +31,9 @@
31
31
  "test": "bun test"
32
32
  },
33
33
  "dependencies": {
34
- "@ultimat3/core": "4.0.0",
35
- "@ultimat3/i18n": "4.0.0",
36
- "@ultimat3/schema": "4.0.0",
37
- "@ultimat3/time": "4.0.0"
34
+ "@ultimat3/core": "4.1.0",
35
+ "@ultimat3/i18n": "4.1.0",
36
+ "@ultimat3/schema": "4.1.0",
37
+ "@ultimat3/time": "4.1.0"
38
38
  }
39
39
  }
package/src/error-map.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // The one place a framework error code becomes an HTTP status. A table, not a
2
2
  // switch chain: adding a code elsewhere in the framework means adding a row here,
3
3
  // and a missing row is a loud 500 rather than a silently wrong 200.
4
- import { renderCauseValue, stringField } from '@ultimat3/core';
4
+ import { renderCauseValue, singleLine, stringField } from '@ultimat3/core';
5
5
  import { errorStatusInvalid, HTTP_ERROR_TITLES } from './errors';
6
6
 
7
7
  /**
@@ -385,5 +385,12 @@ export const toProblem = (
385
385
  /** The exact three lines the terminal prints, reused by the overlay and `--json`. */
386
386
  export const renderErrorLines = (error: unknown): string => {
387
387
  const facts = factsOf(error);
388
- return `${facts.code}: ${facts.title}\n cause: ${facts.cause}\n fix: ${facts.fix}`;
388
+ // The newlines here are the format's own. Every interpolated field goes through `singleLine`
389
+ // so a caller-controlled value cannot add a third one — this string is rendered into the dev
390
+ // overlay's `<pre>`, where HTML escaping does not help because a newline is not markup.
391
+ return [
392
+ `${singleLine(facts.code)}: ${singleLine(facts.title)}`,
393
+ ` cause: ${singleLine(facts.cause)}`,
394
+ ` fix: ${singleLine(facts.fix)}`,
395
+ ].join('\n');
389
396
  };