Skip to content

Commit aa171d7

Browse files
committed
Keep utils in main modules folder
1 parent 5c32ad8 commit aa171d7

20 files changed

+94
-94
lines changed

modules/Match.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* jshint -W084 */
22

3-
var Path = require('./utils/Path');
3+
var PathUtils = require('./PathUtils');
44

55
class Match {
66

@@ -34,16 +34,16 @@ function deepSearch(route, pathname, query) {
3434

3535
// No child routes matched; try the default route.
3636
var defaultRoute = route.defaultRoute;
37-
if (defaultRoute && (params = Path.extractParams(defaultRoute.path, pathname)))
37+
if (defaultRoute && (params = PathUtils.extractParams(defaultRoute.path, pathname)))
3838
return new Match(pathname, params, query, [ route, defaultRoute ]);
3939

4040
// Does the "not found" route match?
4141
var notFoundRoute = route.notFoundRoute;
42-
if (notFoundRoute && (params = Path.extractParams(notFoundRoute.path, pathname)))
42+
if (notFoundRoute && (params = PathUtils.extractParams(notFoundRoute.path, pathname)))
4343
return new Match(pathname, params, query, [ route, notFoundRoute ]);
4444

4545
// Last attempt: check this route.
46-
var params = Path.extractParams(route.path, pathname);
46+
var params = PathUtils.extractParams(route.path, pathname);
4747
if (params)
4848
return new Match(pathname, params, query, [ route ]);
4949

@@ -56,8 +56,8 @@ function deepSearch(route, pathname, query) {
5656
* succeeds, null if no match can be made.
5757
*/
5858
Match.findMatchForPath = function (routes, path) {
59-
var pathname = Path.withoutQuery(path);
60-
var query = Path.extractQuery(path);
59+
var pathname = PathUtils.withoutQuery(path);
60+
var query = PathUtils.extractQuery(path);
6161
var match = null;
6262

6363
for (var i = 0, len = routes.length; match == null && i < len; ++i)

modules/utils/Path.js renamed to modules/PathUtils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function compilePattern(pattern) {
3333
return _compiledPatterns[pattern];
3434
}
3535

36-
var Path = {
36+
var PathUtils = {
3737

3838
/**
3939
* Returns true if the given path is absolute.
@@ -141,19 +141,19 @@ var Path = {
141141
* query merged into the query string.
142142
*/
143143
withQuery: function (path, query) {
144-
var existingQuery = Path.extractQuery(path);
144+
var existingQuery = PathUtils.extractQuery(path);
145145

146146
if (existingQuery)
147147
query = query ? merge(existingQuery, query) : existingQuery;
148148

149149
var queryString = qs.stringify(query, { indices: false });
150150

151151
if (queryString)
152-
return Path.withoutQuery(path) + '?' + queryString;
152+
return PathUtils.withoutQuery(path) + '?' + queryString;
153153

154154
return path;
155155
}
156156

157157
};
158158

159-
module.exports = Path;
159+
module.exports = PathUtils;

modules/Route.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
var assign = require('react/lib/Object.assign');
22
var invariant = require('react/lib/invariant');
33
var warning = require('react/lib/warning');
4-
var Path = require('./utils/Path');
4+
var PathUtils = require('./PathUtils');
55

66
class Route {
77

88
constructor(name, path, ignoreScrollBehavior, isDefault, isNotFound, onEnter, onLeave, handler) {
99
this.name = name;
1010
this.path = path;
11-
this.paramNames = Path.extractParamNames(this.path);
11+
this.paramNames = PathUtils.extractParamNames(this.path);
1212
this.ignoreScrollBehavior = !!ignoreScrollBehavior;
1313
this.isDefault = !!isDefault;
1414
this.isNotFound = !!isNotFound;
@@ -104,7 +104,7 @@ Route.createRoute = function (options, callback) {
104104
var path = options.path || name;
105105

106106
if (path) {
107-
if (Path.isAbsolute(path)) {
107+
if (PathUtils.isAbsolute(path)) {
108108
if (parentRoute) {
109109
invariant(
110110
parentRoute.paramNames.length === 0,
@@ -114,7 +114,7 @@ Route.createRoute = function (options, callback) {
114114
}
115115
} else if (parentRoute) {
116116
// Relative paths extend their parent.
117-
path = Path.join(parentRoute.path, path);
117+
path = PathUtils.join(parentRoute.path, path);
118118
} else {
119119
path = '/' + path;
120120
}

modules/ScrollHistory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var invariant = require('react/lib/invariant');
22
var canUseDOM = require('react/lib/ExecutionEnvironment').canUseDOM;
3-
var getWindowScrollPosition = require('./utils/getWindowScrollPosition');
3+
var getWindowScrollPosition = require('./getWindowScrollPosition');
44

55
function shouldUpdateScroll(state, prevState) {
66
if (!prevState)

modules/StateContext.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var assign = require('react/lib/Object.assign');
22
var PropTypes = require('./PropTypes');
3-
var Path = require('./utils/Path');
3+
var PathUtils = require('./PathUtils');
44

55
function routeIsActive(activeRoutes, routeName) {
66
return activeRoutes.some(function (route) {
@@ -68,7 +68,7 @@ var StateContext = {
6868
* Returns true if the given route, params, and query are active.
6969
*/
7070
isActive: function (to, params, query) {
71-
if (Path.isAbsolute(to))
71+
if (PathUtils.isAbsolute(to))
7272
return to === this.state.path;
7373

7474
return routeIsActive(this.state.routes, to) &&

modules/utils/TestHandlers.js renamed to modules/TestUtils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var React = require('react');
2-
var RouteHandler = require('../components/RouteHandler');
3-
var State = require('../State');
2+
var RouteHandler = require('./components/RouteHandler');
3+
var State = require('./State');
44

55
exports.Nested = React.createClass({
66
render: function () {

modules/__tests__/History-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var expect = require('expect');
22
var React = require('react');
3-
var { Foo, RedirectToFoo } = require('../utils/TestHandlers');
3+
var { Foo, RedirectToFoo } = require('../TestUtils');
44
var TestLocation = require('../locations/TestLocation');
55
var Route = require('../components/Route');
66
var History = require('../History');

0 commit comments

Comments
 (0)