Skip to content

Latest commit

 

History

History
258 lines (160 loc) · 4.47 KB

parser.js.md

File metadata and controls

258 lines (160 loc) · 4.47 KB

Snapshot report for test/parser.js

The actual snapshot is saved in parser.js.snap.

Generated by AVA.

1.1 Parse custom header

parser("content-disposition: inline; filename=example.pdf")

{
  filename: 'example.pdf',
  type: 'inline',
}

1.2 Parse custom header

parser("content-disposition: form-data; name=\"field2\"; filename=\"example.txt\"")

{
  filename: 'example.txt',
  name: 'field2',
  type: 'form-data',
}

1.3 Parse custom header

parser("Content-Disposition: attachment; FileName=\"A LiTTle 'sTrAnge'.fileName\"")

{
  filename: 'A LiTTle \'sTrAnge\'.fileName',
  type: 'attachment',
}

1.4 Parse custom header

parser("Content-Disposition: Attachment; Filename*=UTF-8'en'an%20example")

{
  encoding: 'utf-8',
  filename: 'an example',
  type: 'attachment',
}

1.5 Parse custom header

parser("Content-Disposition: attachment; filename*= UTF-8''%E2%82%B4%20rates")

{
  encoding: 'utf-8',
  filename: '₴ rates',
  type: 'attachment',
}

1.6 Parse custom header

parser("Content-Disposition: attachment; filename=\"EURO rates\"; filename*=utf-8''%e2%82%ac%20rates")

{
  encoding: 'utf-8',
  filename: '€ rates',
  type: 'attachment',
}

1.7 Parse custom header

parser("Content-Disposition: attachment; filename*=utf-8''%24%20rates; filename=\"USD rates\"")

{
  encoding: 'utf-8',
  filename: '$ rates',
  type: 'attachment',
}

1.8 Parse custom header

parser("inline; filename=example.txt")

{
  filename: 'example.txt',
  type: 'inline',
}

1.9 Parse custom header

parser("attachment; filename=\"oїÃ¡Ã¨kа.jpg\"")

{
  filename: 'oїÃ¡Ã¨kа.jpg',
  type: 'attachment',
}

1.10 Parse custom header

parser("attachment; filename=oїÃ¡Ã¨kа.jpg")

{
  filename: 'oїÃ¡Ã¨kа.jpg',
  type: 'attachment',
}

1.11 Parse custom header

parser("inline; filename*=iso-8859-1")

{
  encoding: 'iso-8859-1',
  type: 'inline',
}

1.12 Parse custom header

parser("inline; filename*=iso-8859-1'en'%C3%A9xampl%C3%A9.txt")

{
  encoding: 'iso-8859-1',
  filename: 'éxamplé.txt',
  type: 'inline',
}

1.13 Parse custom header

parser("inline; filename*=iso-8859-1''26738271 svoboda")

{
  encoding: 'iso-8859-1',
  filename: '26738271 svoboda',
  type: 'inline',
}

1.14 Parse custom header

parser("googleit=8{; filename=\"26738271 svoboda\"; filename*=utf-8''%D1%83%D0%B1%D0%B8%D0%B9%20%D1%83%20%D1%81%D0%BE%D0%B1%D1%96%20%D1%81%D0%B2%D0%BE%D0%B1%D0%BE%D0%B4%D0%B0")

{
  encoding: 'utf-8',
  filename: 'убий у собі свобода',
  type: 'googleit=8{',
}

2.1 Parse any string

parse("Any string will be parsed as Content-Disposition type")

{
  type: 'any string will be parsed as content-disposition type',
}

2.2 Parse any string with semicolons

parse("String will semicolons; will be parsed as properties; like; it=is a valid; content=disposition ; sic!;")

{
  content: 'disposition',
  it: 'is a valid',
  like: true,
  'sic!': true,
  type: 'string will semicolons',
  'will be parsed as properties': true,
}

3.1 Handle "" as input

parse("")

undefined

3.2 Handle ";" as input

parse(";")

undefined

3.3 Handle "; string with leading semicolon" as input

parse("; string with leading semicolon")

{
  type: 'string with leading semicolon',
}

3.4 Handle null as input

parse(null)

undefined

3.5 Handle undefined as input

parse(undefined)

undefined

3.6 Handle false as input

parse(false)

undefined

3.7 Handle true as input

parse(true)

undefined

3.8 Handle 0 as input

parse(0)

undefined

3.9 Handle 1 as input

parse(1)

undefined

3.10 Handle -1 as input

parse(-1)

undefined

3.11 Handle NaN as input

parse(NaN)

undefined

3.12 Handle Infinity as input

parse(Infinity)

undefined

3.13 Handle [] as input

parse([])

undefined

3.14 Handle {} as input

parse({})

undefined

3.15 Handle function () {} as input

parse(function () {})

undefined

3.16 Handle function Date() { [native code] } as input

parse(function Date() { [native code] })

undefined