@@ -120,24 +120,35 @@ function specify(type, spec, index) {
120120
121121}
122122
123- function preferredMediaTypes ( accept , provided , detailed ) {
123+ /**
124+ * Returns a list of the acceptable media ranges in preferred order.
125+ *
126+ * @param {string } accept The raw contents of the `Accept` header
127+ * @param {string[] } provided The media ranges the server can produce
128+ * for the resource in question.
129+ * @param {Object } options Configuration options
130+ * @param {boolean } options.detailed When `provided` is not defined, such
131+ * that the caller is asking for a list of _all_ the parsed media types,
132+ * setting this option to true returns an {type, parameters, q} object
133+ * for each type, rather just than a string.
134+ */
135+ function preferredMediaTypes ( accept , provided , options ) {
124136 // RFC 2616 sec 14.2: no header = */*
125137 var accepts = parseAccept ( accept === undefined ? '*/*' : accept || '' ) ;
126138
127139 if ( ! provided ) {
128140 // sorted list of all types
129141 var sorted = accepts . filter ( isQuality ) . sort ( compareSpecs ) ;
130142
131- if ( ! detailed ) {
143+ if ( ! options . detailed ) {
132144 return sorted . map ( function ( spec ) {
133145 return spec . full ;
134146 } ) ;
135147 } else {
136148 return sorted . map ( function ( spec ) {
137149 return {
138- type : spec . type ,
139- subtype : spec . subtype ,
140- params : spec . params ,
150+ type : "" + spec . type + '/' + spec . subtype ,
151+ parameters : spec . params ,
141152 q : spec . q
142153 } ;
143154 } ) ;
0 commit comments