Topic: [Feature] (client-side JS) Remove extra spaces when user searches tags

Posted under Site Bug Reports & Feature Requests

" anthro solo " (there are two spaces between the words that you can't see due to forum page formatting) ends up requesting "e621.net/posts?tags=+anthro++solo+"
" anthro solo " should become "anthro solo" and therefore "e621.net/posts?tags=anthro+solo"

this can be easily cleaned up client-side (onclick event for the #search-box button) prior to sending the GET request with the two javascript string methods replace, to remove redundant spaces between words via regex, and trim, to remove trailing and leading whitespace:
str.replace(/\s+/g, ' ').trim();

I think it should leave 1 trailing space, like you get when editing tags. It makes entering a new tag that much more convenient.

animperfectpatsy said:
I think it should leave 1 trailing space, like you get when editing tags. It makes entering a new tag that much more convenient.

But it also messes up the request URL. If I click "pokémon" in the tag list, it queries https://e621.net/posts?tags=pok%C3%A9mon. If I type in "pok" and pick the "pokémon" autocomplete and hit search, it'll query https://e621.net/posts?tags=pok%C3%A9mon++ (there's two extra spaces there). If I had searched for "pokémon anthro" and just removed the "anthro", it would then query https://e621.net/posts?tags=pok%C3%A9mon+. It's ugly to see those +s in the URL bar, and also messes up the browser's autocomplete and usage analysis (there's three pokemon-only query URLS, and your use of them is spread out among the three, so the browser thinks you're going to three separate pages less frequently instead of one page more frequently).

It looks like this is generally an autocomplete bug, since it adds spaces in various places and then doesn't clean them up again. I will add it to my list to have the autocomplete system try to be more proactive about ensuring that the search term is generally correct and trimmed.

  • 1