Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spaces in search query result in TypeError #8

Open
ericdrobinson opened this issue Apr 3, 2017 · 1 comment
Open

Spaces in search query result in TypeError #8

ericdrobinson opened this issue Apr 3, 2017 · 1 comment

Comments

@ericdrobinson
Copy link

ericdrobinson commented Apr 3, 2017

It is possible to have spaces in the search query. When run in a Node environment, at least, this results in a TypeError in makeRequest. It appears as though the makeUri method does not properly URIEncode the space character.

The same problem actually plagues an empty search query as well (e.g. searching tags only). This is because the empty string is replaced with a single space character (" "), which hits the same problem mentioned above.

I was able to bypass the empty search query issue locally by simply removing that space character and leaving it as the empty string (""). I am not sure if this works as expected or if it breaks something else that is expected.

@ericdrobinson ericdrobinson changed the title Empty search query results in TypeError Spaces in search query result in TypeError Apr 3, 2017
@ericdrobinson
Copy link
Author

A workaround appears to be passing in an already encoded string. E.g.:
freesound.textSearch(encodeURIComponent(" "), ...);

It appears that searching for an encoded "space" character is equivalent to searching with an empty string.

A fix to handle this internally might look something like:
query = encodeURIComponent(query);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant