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

Update page to 1.11.5 #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .npm/package/npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 31 additions & 4 deletions client/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,26 @@ class Router {
return new Group(this, options);
}

basePath (pathStr) {
if (typeof pathStr === 'undefined') {
return this._basePath
}

let _basePath = pathStr || '' // in case null is passed

if (!_basePath.startsWith('/')) {
_basePath = `/${_basePath}`;
}

if (_basePath.endsWith('/')) {
const end = _basePath.length - 1
_basePath = _basePath.substring(0, end)
}

this._basePath = _basePath
return this._basePath
}

path(_pathDef, fields = {}, queryParams) {
let pathDef = _pathDef;
if (this._routesMap[pathDef]) {
Expand Down Expand Up @@ -454,7 +474,7 @@ class Router {
if (!path || (!self.env.reload.get() && self._current.path === path)) {
return;
}
original.call(this, path.replace(/\/\/+/g, '/'), state, dispatch, push);
original.call(self, path.replace(/\/\/+/g, '/'), state, dispatch, push);
};
});

Expand All @@ -464,11 +484,18 @@ class Router {
// we are doing a hack. see .path()
this._page.base(this._basePath);

this._page(Object.assign({

const pageOptions = Object.assign({
click: true,
popstate: true,
dispatch: false,
hashbang: !!options.hashbang,
decodeURLComponents: true
}, options.page || {}));
decodeURLComponents: true,
window: window
}, options.page || {});


this._page.call(null, pageOptions);
this._initialized = true;
}

Expand Down
2 changes: 1 addition & 1 deletion package.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Package.onTest((api) => {
});

Npm.depends({
page: '1.9.0',
page: '1.11.5',
qs: '6.5.2'
});
8 changes: 6 additions & 2 deletions test/client/router.core.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,11 @@ Tinytest.add('Client - Router - base path - path generation', (test) => {
_.each(['/flow', '/flow/', 'flow/', 'flow'], function(simulatedBasePath) {
const rand = Random.id();
setBasePath(simulatedBasePath);
test.equal(FlowRouter.path('/' + rand), '/flow/' + rand);
test.equal(FlowRouter._basePath, '/flow')

const expected = '/flow/' + rand
const actual = FlowRouter.path('/' + rand)
test.equal(actual, expected);
});
resetBasePath();
});
Expand All @@ -633,7 +637,7 @@ Tinytest.add('Client - Router - base path - url generation', (test) => {

function setBasePath(path) {
FlowRouter._initialized = false;
FlowRouter._basePath = path;
FlowRouter.basePath(path);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jankapunkt Wouldn’t it be major changes?
Maybe we can change _basePath to setter instead of function?

FlowRouter.initialize();
}

Expand Down