webrtc-ice.js 447 B

1234567891011121314
  1. export function coerceIceServerList(list) {
  2. if (!Array.isArray(list) || !list.length) return null
  3. return list.map((entry) => {
  4. if (!entry || typeof entry !== 'object') return entry
  5. const normalized = { ...entry }
  6. if (typeof normalized.urls === 'string') {
  7. normalized.urls = [normalized.urls]
  8. } else if (normalized.url && !normalized.urls) {
  9. normalized.urls = [normalized.url]
  10. delete normalized.url
  11. }
  12. return normalized
  13. })
  14. }