Last active
August 29, 2015 14:24
-
-
Save markoheijnen/1fa920d41a6bbe6b7797 to your computer and use it in GitHub Desktop.
Parsing props
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
function get_props( description ) { | |
var users = []; | |
// Cleanup for easier parsing. | |
description = description.toLowerCase().replace( /[\n|, ]fixes(.*)/i, '' ).replace( /(\n|. )see(.*)/i, '' ); | |
// Place enter to fix cases where it otherwise would fail. See changeset 22094 | |
if ( '.' != description.substr(description.length - 1) ) { | |
description += '.'; | |
} | |
// Get the props part | |
var props = description.match(/\nprops(.*)./i); | |
// If there are props then clean it out and build up an array. | |
if ( props !== null ) { | |
// Replace and with a comma so array can be build. | |
users = props[1].trim().replace(' and ', ', '); | |
// Build array | |
users = users.split( /\s*,\s*/ ); | |
// Clean usernames up | |
users = users.map( function(user) { | |
user = user.replace(' for the original patch', ''); | |
user = user.replace(' for initial patch', ''); | |
user = user.replace(' for the initial patch', ''); | |
user = user.replace(' for the original js file and concept', ''); | |
user = user.replace(' for the original js file', ''); | |
user = user.replace(' for troubleshooting', ''); | |
user = user.replace(' for first patch and testing', ''); | |
user = user.replace(' for patches', ''); | |
user = user.replace(' for the exhaustive research', ''); | |
user = user.replace(' for the assist', ''); | |
return user; | |
}); | |
// Remove empty and incorrect values | |
users = users.filter(function(e){ | |
// ignore and. | |
if ( 'and' == e ) { | |
return false; | |
} | |
return e; | |
}); | |
} | |
return users; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment