Skip to content

Commit

Permalink
Merge pull request #27 from qubyte/allow-empty-language-in-extended-e…
Browse files Browse the repository at this point in the history
…ncoding

Allow an empty language section in extended header encoding.
  • Loading branch information
jhermsmeier committed Jul 2, 2022
2 parents b191287 + 8bf518d commit 82d0580
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ Link.expandRelations = function( ref ) {
* @return {Object}
*/
Link.parseExtendedValue = function( value ) {
var parts = /([^']+)?(?:'([^']+)')?(.+)/.exec( value )
var parts = /([^']+)?(?:'([^']*)')?(.+)/.exec( value )
return {
language: parts[2].toLowerCase(),
encoding: Link.isCompatibleEncoding( parts[1] ) ?
Expand Down
14 changes: 14 additions & 0 deletions test/encoding.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,18 @@ context( 'Encodings', function() {
assert.deepEqual( link.refs, refs )
})

test( 'language optional', function() {
var link = Link.parse( '</risk-mitigation>; rel="start"; title*=UTF-8\'\'%E2%91%A0%E2%93%AB%E2%85%93%E3%8F%A8%E2%99%B3%F0%9D%84%9E%CE%BB' )
var refs = [{
uri: '/risk-mitigation',
rel: 'start',
'title*': {
language: '',
encoding: null,
value: '①⓫⅓㏨♳𝄞λ'
},
}]
// console.log( inspect( link ) )
assert.deepEqual( link.refs, refs )
})
})

0 comments on commit 82d0580

Please sign in to comment.