Skip to content

Commit

Permalink
Merge pull request #32 from csarven/fix/typeerror-referenced-attribute
Browse files Browse the repository at this point in the history
Avoid TypeError when referenced attribute is undefined
  • Loading branch information
jhermsmeier committed Mar 16, 2024
2 parents 1389ddb + 629d9c6 commit 0d043d5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class Link {
var type = value.toLowerCase()

for( var i = 0; i < this.refs.length; i++ ) {
if( this.refs[ i ].rel.toLowerCase() === type ) {
if( typeof this.refs[ i ].rel === 'string' && this.refs[ i ].rel.toLowerCase() === type ) {
links.push( this.refs[ i ] )
}
}
Expand All @@ -108,7 +108,7 @@ class Link {
var links = []

for( var i = 0; i < this.refs.length; i++ ) {
if( this.refs[ i ][ attr ].toLowerCase() === value ) {
if( typeof this.refs[ i ][ attr ] === 'string' && this.refs[ i ][ attr ].toLowerCase() === value ) {
links.push( this.refs[ i ] )
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ class Link {
value = value.toLowerCase()

for( var i = 0; i < this.refs.length; i++ ) {
if( this.refs[ i ][ attr ].toLowerCase() === value ) {
if( typeof this.refs[ i ][ attr ] === 'string' && this.refs[ i ][ attr ].toLowerCase() === value ) {
return true
}
}
Expand Down

0 comments on commit 0d043d5

Please sign in to comment.