@@ -16,7 +16,7 @@ const parse = require('./utils').parse
1616const fetch = require ( 'node-fetch' )
1717const { promisify } = require ( 'util' )
1818
19- const DEFAULT_CONTENT_TYPE = 'text/turtle'
19+ const DEFAULT_REMOTE_CONTENT_TYPE = 'text/turtle'
2020
2121const RDF_MIME_TYPES = [
2222 'text/turtle' , // .ttl
@@ -197,7 +197,7 @@ class LDP {
197197 *
198198 * @return {Promise<Graph> }
199199 */
200- async putGraph ( graph , uri , contentType = DEFAULT_CONTENT_TYPE ) {
200+ async putGraph ( graph , uri , contentType ) {
201201 const { path } = url . parse ( uri )
202202 const content = await serialize ( graph , uri , contentType )
203203 let stream = stringToStream ( content )
@@ -286,7 +286,7 @@ class LDP {
286286 }
287287 const body = await response . text ( )
288288
289- const contentType = options . contentType || DEFAULT_CONTENT_TYPE
289+ const contentType = options . contentType || DEFAULT_REMOTE_CONTENT_TYPE
290290
291291 return promisify ( parse ) ( body , uri , contentType )
292292 }
@@ -309,12 +309,15 @@ class LDP {
309309 *
310310 * @return {Promise<Graph> }
311311 */
312- getGraph ( uri , contentType = DEFAULT_CONTENT_TYPE ) {
312+ getGraph ( uri , contentType ) {
313313 return this . graph ( uri , uri , contentType )
314314 }
315315
316- async graph ( url , baseUri , contentType = DEFAULT_CONTENT_TYPE ) {
316+ async graph ( url , baseUri , contentType ) {
317317 const body = await this . readResource ( url )
318+ if ( ! contentType ) {
319+ ( { contentType } = await this . resourceMapper . mapUrlToFile ( { url } ) )
320+ }
318321 return new Promise ( ( resolve , reject ) => {
319322 const graph = $rdf . graph ( )
320323 $rdf . parse ( body , graph , baseUri , contentType ,
0 commit comments