Path name with '/' inside it route with iron-router


#1

Hello community,
I’ve got a problem with iron-router.
My problem is:
I make a website for a musician friend, he can create project, I have a page where all the projects are,
and if you click on a project inside this page, iron router make the client go on the project page (inside the site). The problem is that he’s got projects with the ‘/’ inside the name now. So iron:router can’t understand what I mean.


Router.route(`/projects/:projectName`, {
    name: "project",
    data: function() {
        return Projects.findOne({name:this.params.projectName});
    },
    waitOn: function() {
        return [
            Meteor.subscribe("Projects",{name:this.params.projectName}),
            Meteor.subscribe("Dates",{relatedProjects: this.params.projectName}),
            Meteor.subscribe("Compositions",{relatedProjects: this.params.projectName}),
            Meteor.subscribe("Videos",{relatedProjects: this.params.projectName}),
            Meteor.subscribe("Albums",{relatedProjects: this.params.projectName})
        ];
    }
});

The problem could have gone easy if I knew that before, because instead of the projectName I could just go withthe id, and I would’nt have any problem. but can’t do this now, all the database is working with projectNames…
So I just want to change the project page path to a safer name like (projectName.replace(///g,"+")) but keep the projectName for subscriptions.

I try to pass multiple arguments to Router.go, in the purpose of having the both data I need:

Router.go("project", { projectName:this.name, projectPath: this.name.replace(/\//g,"+") });
But inside the route, the route only knows the params write after the ‘:’. So if I wrote:

Router.route("/projects/:projectPath", …
He doesn’t know anymore the projectName.
I hope I’m understandable…

Thanks for your help !


#2

Nobody can help me with it ?