Skip to content

Commit

Permalink
fix: getStationsById when using multiple IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandotv committed Jul 17, 2021
2 parents 9ad1fa5 + 6e53fe0 commit 4f8e5f3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ node_modules
/dist
/.buildcache
/.vscode/settings.json
/.vs
/scratch
/reports
/temp
Expand Down
6 changes: 3 additions & 3 deletions src/radioBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,9 @@ export class RadioBrowserApi {

for (const response of stations) {
if (removeDuplicates) {
const nameAndUrl = `${response.name
const nameAndUrl = `${response.name.toLowerCase().trim()}${response.url
.toLowerCase()
.trim()}${response.url.toLowerCase().trim()}`
.trim()}`

// guard against results having the same stations under different id's
if (duplicates[nameAndUrl]) continue
Expand Down Expand Up @@ -405,7 +405,7 @@ export class RadioBrowserApi {
const stationsIds = ids.join(',')
const stations = await this.runRequest<StationResponse[]>(
this.buildRequest(
`stations/byuuid/${stationsIds}`,
`stations/byuuid?uuids=${stationsIds}`,
undefined,
undefined,
false
Expand Down
4 changes: 2 additions & 2 deletions tests/radioBrowser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StationSearchType } from '../src/constants'
import { RadioBrowserApi } from '../src/radioBrowser'
import { getMockStation, getMockResponse } from './utils/mockStation'

global.fetch = (nodeFetch as unknown) as typeof fetch
global.fetch = nodeFetch as unknown as typeof fetch

const resolvedServer = 'fr1.api.radio-browser.info'
const baseUrl = `https://${resolvedServer}`
Expand Down Expand Up @@ -947,7 +947,7 @@ describe('Radio Browser', () => {
'user-agent': appName
}
})
.get(`/json/stations/byuuid/${stationIds.join(',')}`)
.get(`/json/stations/byuuid?uuids=${stationIds.join(',')}`)
.reply(200, mockResult)

const result = await api.getStationsById(stationIds, {
Expand Down

0 comments on commit 4f8e5f3

Please sign in to comment.