Class ExtensionBasedMapper

Supports the behaviour described in Determines content-type based on the file extension. In case an identifier does not end on an extension matching its content-type, the corresponding file will be appended with the correct extension, preceded by $.




baseRequestURI: string
customExtensions: Record<string, string>
customTypes: Record<string, string>
logger: Logger = ...
rootFilepath: string
unknownMediaTypeExtension: "unknown" = 'unknown'


  • Maps the given document identifier to a file path, possibly making alterations to the direct translation (for instance, based on its content type)). Determines the content type if none was provided.


    • identifier: ResourceIdentifier

      The input identifier.

    • filePath: string

      The direct translation of the identifier onto the file path.

    • Optional contentType: string

      The content-type provided with the request.

    Returns Promise<ResourceLink>

    A ResourceLink with all the necessary metadata.

  • Helper function that removes the internal extension, one starting with $., from the given path. Nothing happens if no such extension is present.


    • path: string

    Returns string