I need to match a path into an URL. The path has to be the end of the URL after a given pattern, but I can't do it. Ember.js always end it's matching to the next slash.
var router = Ember.Router.extend({
location: 'history',
enableLogging: true,
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/'
repo: Ember.Route.extend({
route: '/:repo_id',
index: Ember.Route.extend({
route: '/'
}),
files: Ember.Route.extend({
route: '/files',
index: Ember.Route.extend({
route: '/'
}),
sub: Ember.Route.extend({
route: '/:path'
})
})
})
})
})
});
With this router:
/myrepo/files/
will matchroot.repo.files.index
/myrepo/files/README
will matchroot.repo.files.sub
withpath=README
/myrepo/files/folder/README
will matchroot.repo.files.sub
and will reroute me to/myrepo/files/folder/
becausepath=folder
instead ofpath=folder/README
How can I to have sub route match the end of URL with :path
even when there is slash into it or not ?
There is an opened issue on Ember.js Github Tracker: https://github.com/emberjs/ember.js/issues/1451
This functionality has been committed to the Ember.js repository's master branch. It is not in the
1.0.0-pre2
build, so until a new version is released you will need to either build Ember.js yourself or find a prebuilt version.Basic Usage
Instead of prefixing your dynamic segment with a colon
:
, use an asterisk*
. Your route will use a syntax similar to:The path segment will be available just as if it were a normal dynamic property. However, it will include anything after
files/
in the URL, including slashes.