arowM / elm-data-url / DataUrl.MediaType

A module to handle media types of data URLs (IETF RFC 2397) in type safe manner.

This module only provides a opaque type and getters, so there are no way to construct new MediaType. The only way to get MediaType is using DataUrl.mediaType, which picks MediaType value from DataUrl value.

Types


type alias MediaType =
Internal.MediaType

An opaque type representing the media type part of data urls.

Convert functions

toString : MediaType -> String

Convert MediaType value to string representation.

import DataUrl.MediaType.Internal exposing (sampleMediaType)

DataUrl.MediaType.toString sampleMediaType
--> "text/plain;charset=iso-8859-7"

Getters

type_ : MediaType -> ( String, String )

Take pair of type and subtype from MediaType value. The type and subtype is guaranteed to meet type-name and subtype-name in IETF RFC 6838 respectively, which is not as strict as IETF RFC 2397 requires, when created by DataUrl.fromString.

import DataUrl.MediaType.Internal exposing (sampleMediaType)

type_ sampleMediaType
--> ( "text", "plain" )

parameters : MediaType -> List ( String, String )

Take list of key-value pair of parameters from MediaType value. The parameter key and value is guaranteed to meet attribute and value in IETF RFC 2045 respectively, as IETF RFC 2397 requires, when created by DataUrl.fromString.

import DataUrl.MediaType.Internal exposing (sampleMediaType)

parameters sampleMediaType
--> [ ( "charset", "iso-8859-7" ) ]