-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update:Book series embeds in grouping meta tag as semicolon deliminat…
…ed, book meta tag parser falls back to using grouping tag for series if set #3473
- Loading branch information
Showing
6 changed files
with
65 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* Parse a series string into a name and sequence | ||
* | ||
* @example | ||
* Name #1a => { name: 'Name', sequence: '1a' } | ||
* Name #1 => { name: 'Name', sequence: '1' } | ||
* | ||
* @param {string} seriesString | ||
* @returns {{name: string, sequence: string}|null} | ||
*/ | ||
module.exports.parse = (seriesString) => { | ||
if (!seriesString || typeof seriesString !== 'string') return null | ||
|
||
let sequence = null | ||
let name = seriesString | ||
// Series sequence match any characters after " #" other than whitespace and another # | ||
// e.g. "Name #1a" is valid. "Name #1#a" or "Name #1 a" is not valid. | ||
const matchResults = seriesString.match(/ #([^#\s]+)$/) // Pull out sequence # | ||
if (matchResults && matchResults.length && matchResults.length > 1) { | ||
sequence = matchResults[1] // Group 1 | ||
name = seriesString.replace(matchResults[0], '') | ||
} | ||
return { | ||
name, | ||
sequence | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters