Talk:Knowing Your Own Metadata

From GreaseSpot Wiki
Revision as of 18:56, 7 December 2012 by Cletus (talk | contribs) (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...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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);
   });