File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 229
229
return transformedFiltered ;
230
230
} ;
231
231
232
- Instafeed . prototype . _getTags = function getTags ( data ) {
233
- // This expression comes from https://github.com/johnlinp/instagram-validator
234
- // A non-official instagram validator
235
- var exp = / ^ # [ ^ ~ ` ! @ # $ % ^ & * \( \) \- \+ = { } \[ \] : ; " ' < > \? , \. / | \\ \s ] + $ / gi;
232
+ Instafeed . prototype . _extractTags = function extractTags ( str ) {
233
+ var exp = / # ( [ ^ \s ] + ) / gi;
234
+ var badChars = / [ ~ ` ! @ # $ % ^ & * \( \) \- \+ = { } \[ \] : ; " ' < > \? , \. / | \\ \s ] + / i; // non-allowed characters
236
235
var tags = [ ] ;
237
- var tagData = data . caption . match ( exp ) || [ ] ;
238
236
239
- //Pull the hash character off the front of each tag.
240
- //Can this be done in one hit with the regex?
241
- for ( var i = 0 ; i < tagData . length ; i ++ ) {
242
- tags . push ( tagData [ i ] . substring ( 1 ) ) ;
237
+ if ( typeof str === 'string' ) {
238
+ while ( ( match = exp . exec ( str ) ) !== null ) {
239
+ if ( badChars . test ( match [ 1 ] ) === false ) {
240
+ tags . push ( match [ 1 ] ) ;
241
+ }
242
+ }
243
243
}
244
244
245
245
return tags ;
266
266
267
267
return {
268
268
caption : data . caption ,
269
- tags : this . _getTags ( data ) ,
269
+ tags : this . _extractTags ( data . caption ) ,
270
270
id : data . id ,
271
271
image : image ,
272
272
link : data . permalink ,
You can’t perform that action at this time.
0 commit comments