MCPcopy Index your code
hub / github.com/PDMLab/http-problem-details / constructor

Method constructor

src/ProblemDocument.ts:11–58  ·  view source on GitHub ↗
(options: ProblemDocumentOptions, extension?: ProblemDocumentExtension | Record<string, Object>)

Source from the content-addressed store, hash-verified

9 public type?: string
10
11 public constructor (options: ProblemDocumentOptions, extension?: ProblemDocumentExtension | Record<string, Object>) {
12 const detail = options.detail
13 const instance = options.instance
14 let type = options.type
15 let title = options.title
16 const status = options.status
17
18 if (status && !type) {
19 type = 'about:blank'
20 }
21
22 if (status && type === 'about:blank') {
23 title = statusCodes[status]
24 }
25
26 if (instance) {
27 // eslint-disable-next-line node/no-deprecated-api
28 url.parse(instance)
29 }
30
31 if (type) {
32 // eslint-disable-next-line node/no-deprecated-api
33 url.parse(type)
34 // eslint-disable-next-line node/no-deprecated-api
35 }
36
37 // const result = {
38 this.type = type
39 this.title = title
40 if (detail) {
41 this.detail = detail
42 }
43 this.instance = instance
44 this.status = status
45 // };
46
47 if (extension) {
48 const extensionProperties = extension instanceof ProblemDocumentExtension
49 ? extension.extensionProperties
50 : extension
51
52 for (const propertyName in extensionProperties) {
53 if (extensionProperties.hasOwnProperty(propertyName)) {
54 this[propertyName] = extensionProperties[propertyName]
55 }
56 }
57 }
58 }
59}
60
61export class ProblemDocumentOptions {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected