Source

services/position-service.js

/**
 * Valid APIV3 position id has the following format: {serverId}_{boxId}_{timestamp80}
 *
 * Count the number of occurences of one character in the string
 * ("41_123_12312312312".match(new RegExp("_", "g")) || []).length
 * @param {*} positionId
 * @returns
 */
export function isValidPositionId(positionId) {
  return (
    positionId &&
    (positionId || '').toString().includes('_') &&
    !(positionId || '').toString().includes('id_') &&
    ((positionId || '').toString().match(new RegExp('_', 'g')) || []).length ===
      2
  )
}