Talk:Knowing Your Own Metadata: Difference between revisions

From GreaseSpot Wiki
Jump to navigationJump to search
(Created page with "The "parseHeaders" function contains an error with the "filter" method on line 5. It returns this error when attempting to use it: TypeError: /\/\/ @/ is not a function on...")
 
(No difference)

Latest revision as of 18:56, 7 December 2012

The "parseHeaders" function contains an error with the "filter" method on line 5. It returns this error when attempting to use it:

   TypeError: /\/\/ @/ is not a function

on this line:

   var lines = metadataBlock.split(/\n/).filter(/\/\/ @/);

According to the MDN docs, the argument should be a callback, not a RegExp. As shown on this userscripts.org post, changing it to the following will fix it.

   var lines = metadataBlock.split(/\n/).filter(function (element, index, array) {
       return /\/\/ @/.test(element);
   });