@@ -93,6 +93,18 @@ function googleDrivePath (path) {
9393 return cleanPath ( `${ PATH_PREFIX } /${ path } ` ) ;
9494}
9595
96+ /**
97+ * Remove surrounding quotes from a string.
98+ *
99+ * @param {string } string - string with surrounding quotes
100+ * @returns {string } string without surrounding quotes
101+ *
102+ * @private
103+ */
104+ function removeQuotes ( string ) {
105+ return string . substring ( 1 , string . length - 1 ) ;
106+ }
107+
96108/**
97109 * Internal cache object for storing Google file IDs.
98110 *
@@ -259,7 +271,7 @@ GoogleDrive.prototype = {
259271 function putDone ( response ) {
260272 if ( response . status >= 200 && response . status < 300 ) {
261273 const meta = JSON . parse ( response . responseText ) ;
262- const etagWithoutQuotes = meta . etag . substring ( 1 , meta . etag . length - 1 ) ;
274+ const etagWithoutQuotes = removeQuotes ( meta . etag ) ;
263275 return Promise . resolve ( { statusCode : 200 , contentType : meta . mimeType , revision : etagWithoutQuotes } ) ;
264276 } else if ( response . status === 412 ) {
265277 return Promise . resolve ( { statusCode : 412 , revision : 'conflict' } ) ;
@@ -303,7 +315,7 @@ GoogleDrive.prototype = {
303315 return this . _getMeta ( id ) . then ( ( meta ) => {
304316 let etagWithoutQuotes ;
305317 if ( ( typeof meta === 'object' ) && ( typeof meta . etag === 'string' ) ) {
306- etagWithoutQuotes = meta . etag . substring ( 1 , meta . etag . length - 1 ) ;
318+ etagWithoutQuotes = removeQuotes ( meta . etag ) ;
307319 }
308320 if ( options && options . ifMatch && ( options . ifMatch !== etagWithoutQuotes ) ) {
309321 return { statusCode : 412 , revision : etagWithoutQuotes } ;
@@ -431,7 +443,7 @@ GoogleDrive.prototype = {
431443 return this . _getMeta ( id ) . then ( ( meta ) => {
432444 let etagWithoutQuotes ;
433445 if ( typeof ( meta ) === 'object' && typeof ( meta . etag ) === 'string' ) {
434- etagWithoutQuotes = meta . etag . substring ( 1 , meta . etag . length - 1 ) ;
446+ etagWithoutQuotes = removeQuotes ( meta . etag ) ;
435447 }
436448
437449 if ( options && options . ifNoneMatch && ( etagWithoutQuotes === options . ifNoneMatch ) ) {
@@ -515,7 +527,7 @@ GoogleDrive.prototype = {
515527
516528 itemsMap = { } ;
517529 for ( const item of data . items ) {
518- etagWithoutQuotes = item . etag . substring ( 1 , item . etag . length - 1 ) ;
530+ etagWithoutQuotes = removeQuotes ( item . etag ) ;
519531 if ( item . mimeType === GD_DIR_MIME_TYPE ) {
520532 this . _fileIdCache . set ( path + item . title + '/' , item . id ) ;
521533 itemsMap [ item . title + '/' ] = {
0 commit comments