content-type.js — fastify Source File
Architecture documentation for content-type.js, a javascript file in the fastify codebase.
Entity Profile
Relationship Graph
Source Code
'use strict'
/**
* keyValuePairsReg is used to split the parameters list into associated
* key value pairings.
*
* @see https://httpwg.org/specs/rfc9110.html#parameter
* @type {RegExp}
*/
const keyValuePairsReg = /([\w!#$%&'*+.^`|~-]+)=([^;]*)/gm
/**
* typeNameReg is used to validate that the first part of the media-type
* does not use disallowed characters.
*
* @see https://httpwg.org/specs/rfc9110.html#rule.token.separators
* @type {RegExp}
*/
const typeNameReg = /^[\w!#$%&'*+.^`|~-]+$/
/**
* subtypeNameReg is used to validate that the second part of the media-type
* does not use disallowed characters.
*
* @see https://httpwg.org/specs/rfc9110.html#rule.token.separators
* @type {RegExp}
*/
const subtypeNameReg = /^[\w!#$%&'*+.^`|~-]+\s*/
/**
* ContentType parses and represents the value of the content-type header.
*
* @see https://httpwg.org/specs/rfc9110.html#media.type
* @see https://httpwg.org/specs/rfc9110.html#parameter
*/
class ContentType {
#valid = false
#empty = true
#type = ''
#subtype = ''
#parameters = new Map()
#string
constructor (headerValue) {
if (headerValue == null || headerValue === '' || headerValue === 'undefined') {
return
}
let sepIdx = headerValue.indexOf(';')
if (sepIdx === -1) {
// The value is the simplest `type/subtype` variant.
sepIdx = headerValue.indexOf('/')
if (sepIdx === -1) {
// Got a string without the correct `type/subtype` format.
return
}
const type = headerValue.slice(0, sepIdx).trimStart().toLowerCase()
const subtype = headerValue.slice(sepIdx + 1).trimEnd().toLowerCase()
// ... (93 more lines)
Domain
Subdomains
Classes
Source
Frequently Asked Questions
What does content-type.js do?
content-type.js is a source file in the fastify codebase, written in javascript. It belongs to the CoreKernel domain, LifecycleManager subdomain.
Where is content-type.js in the architecture?
content-type.js is located at lib/content-type.js (domain: CoreKernel, subdomain: LifecycleManager, directory: lib).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free