/**
 * Utility functions for parsing
 *
 */ param { string } value returns { number } function strictParseInt ( value ) { if ( /^([1-9][0-9]*)$/ . test ( value ) ) { return Number ( value ) ; } return NaN ; } param { String } url returns { number | undefined } function parseBuildingURL ( url ) { const re = /\/(\d+)(\/history)?$/ ; const matches = re . exec ( url ) ; if ( matches && matches . length >= 2 ) { return strictParseInt ( matches [ 1 ] ) ; } return undefined ; } param { String } url returns { String } function parseCategoryURL ( url ) { const defaultCat = 'age' ; if ( url === '/' ) { return defaultCat ; } const matches = /^\/(view|edit|multi-edit)\/([^/.]+)/ . exec ( url ) ; const cat = ( matches && matches . length >= 3 ) ? matches [ 2 ] : defaultCat ; return cat ; } export { strictParseInt , parseBuildingURL , parseCategoryURL } ;