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

add url function which returns the absolute url for a path #374

Merged
merged 1 commit into from
Nov 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Router.prototype.url = function() {
var path = this.path.apply(this, arguments);
return Meteor.absoluteUrl(path.replace(/^\//, ''));
};
3 changes: 3 additions & 0 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Package.onTest(function(api) {
api.addFiles('test/server/plugins/fast_render.js', 'server');

api.addFiles('test/common/router.path.spec.js', ['client', 'server']);
api.addFiles('test/common/router.url.spec.js', ['client', 'server']);
api.addFiles('test/common/router.addons.spec.js', ['client', 'server']);
api.addFiles('test/common/route.spec.js', ['client', 'server']);
});
Expand Down Expand Up @@ -75,4 +76,6 @@ function configure(api) {
api.addFiles('server/_init.js', 'server');

api.addFiles('server/plugins/fast_render.js', 'server');

api.addFiles('lib/router.js', ['client', 'server']);
}
11 changes: 11 additions & 0 deletions test/common/router.url.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Tinytest.add('Common - Router - url - generic', function (test) {
var pathDef = "/blog/:blogId/some/:name";
var fields = {
blogId: "1001",
name: "superb"
};
var expectedUrl = Meteor.absoluteUrl('blog/1001/some/superb');

var path = FlowRouter.url(pathDef, fields);
test.equal(path, expectedUrl);
});