Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:19:31+00:00 2026-06-15T13:19:31+00:00

My app basically takes some form input and returns a set of results. I

  • 0

My app basically takes some form input and returns a set of results. I have two routes

routes: {
        '': 'search',
        'search': 'search',
        'results/:query': 'results'
    },
    results: function(query) {
        var search = new ResultsSearchView();
        var grid = new GridView({ query: query });
    }

If the query contains any characters / specifically (can totally happen in this case), they are added to the URL and my route breaks.

I have tried using encodeURI() and encodeURIComponent() bit I’m not having any luck. How are you folks handling such things?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:19:32+00:00Added an answer on June 15, 2026 at 1:19 pm

    You can use encodeURIComponent when building the URL to convert the / to %2F and then decodeURIComponent inside the route handler to convert them back; the HTML would end looking like this:

    <a href="#results/pancakes">no slash</a>
    <a href="#results/where%2Fis%2Fpancakes%2Fhouse">with slashes</a>
    

    and then in the router:

    routes: {
        'results/:query': 'results'
    },
    results: function(query) {
        query = decodeURIComponent(query);
        // Do useful things here...
    }
    

    Demo: http://jsfiddle.net/ambiguous/sbpfD/

    Alternatively, you could use a splat route:

    Routes can contain parameter parts, :param, which match a single URL component between slashes; and splat parts *splat, which can match any number of URL components.

    So your HTML would be like this:

    <a href="#results/pancakes">no slash</a>
    <a href="#results/where/is/pancakes/house">with slashes</a>
    

    and your router:

    routes: {
        'results/*query': 'results'
    },
    results: function(query) {
        // Do useful things here...
    }
    

    Demo: http://jsfiddle.net/ambiguous/awJxG/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Sinatra app that basically takes some input values and then finds
Basically I made console app that performs some task that takes a few minutes.
I have a CI app that has a auth controller and switchuser function. Basically
I have a need for a model(?) on my app which basically contains a
I have about 10 objects on an app's interface. These objects are basically a
After reading some statistics about my app I saw that it takes over one
Basically I have an app that would require things(around 20 index files) to be
I have an app that's basically a fancy PDF reader. I download a PDF
I have the following Listbox in my Windows Phone 7.5 app. Basically the ItemTemplate
So my app is basically a shell with a ContentControl that I populate with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.