Skip to content
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
14 changes: 6 additions & 8 deletions Resources/js/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class Router {
}
});
} else if (typeof params === 'object') {
for (name in params) {
for (const name of Object.keys(params)) {
this.buildQueryParams(prefix + '[' + name + ']', params[name], add);
}
} else {
Expand All @@ -172,9 +172,9 @@ export class Router {
let prefixedSf41i18nName = this.context_.prefix + name + '.' + this.context_.locale;
let variants = [prefixedName, sf41i18nName, prefixedSf41i18nName, name];

for (let i in variants) {
if (variants[i] in this.routes_) {
return this.routes_[variants[i]];
for (const variant of variants) {
if (variant in this.routes_) {
return this.routes_[variant];
}
}

Expand Down Expand Up @@ -296,10 +296,8 @@ export class Router {
queryParams.push(Router.encodeQueryComponent(key) + '=' + Router.encodeQueryComponent(value));
};

for (const prefix in unusedParams) {
if(unusedParams.hasOwnProperty(prefix)) {
this.buildQueryParams(prefix, unusedParams[prefix], add);
}
for (const prefix of Object.keys(unusedParams)) {
this.buildQueryParams(prefix, unusedParams[prefix], add);
}

url = url + '?' + queryParams.join('&');
Expand Down
65 changes: 33 additions & 32 deletions Resources/public/js/router.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
(function (root, factory) {
var routing = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], routing.Routing);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = routing.Routing;
} else {
// Browser globals (root is window)
root.Routing = routing.Routing;
root.fos = {
Router: routing.Router
};
}
}(this, function () {
var exports = {};
(function (root, factory) {
var routing = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], routing.Routing);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = routing.Routing;
} else {
// Browser globals (root is window)
root.Routing = routing.Routing;
root.fos = {
Router: routing.Router
};
}
}(this, function () {
var exports = {};
"use strict";
exports.__esModule = true;
exports.Routing = exports.Router = void 0;
Expand Down Expand Up @@ -109,8 +109,9 @@ var Router = /** @class */ (function () {
});
}
else if (typeof params === 'object') {
for (name in params) {
this.buildQueryParams(prefix + '[' + name + ']', params[name], add);
for (var _i = 0, _a = Object.keys(params); _i < _a.length; _i++) {
var name_1 = _a[_i];
this.buildQueryParams(prefix + '[' + name_1 + ']', params[name_1], add);
}
}
else {
Expand All @@ -125,9 +126,10 @@ var Router = /** @class */ (function () {
var sf41i18nName = name + '.' + this.context_.locale;
var prefixedSf41i18nName = this.context_.prefix + name + '.' + this.context_.locale;
var variants = [prefixedName, sf41i18nName, prefixedSf41i18nName, name];
for (var i in variants) {
if (variants[i] in this.routes_) {
return this.routes_[variants[i]];
for (var _i = 0, variants_1 = variants; _i < variants_1.length; _i++) {
var variant = variants_1[_i];
if (variant in this.routes_) {
return this.routes_[variant];
}
}
throw new Error('The route "' + name + '" does not exist.');
Expand Down Expand Up @@ -230,10 +232,9 @@ var Router = /** @class */ (function () {
value = (value === null) ? '' : value;
queryParams_1.push(Router.encodeQueryComponent(key) + '=' + Router.encodeQueryComponent(value));
};
for (var prefix in unusedParams) {
if (unusedParams.hasOwnProperty(prefix)) {
this.buildQueryParams(prefix, unusedParams[prefix], add);
}
for (var _i = 0, _a = Object.keys(unusedParams); _i < _a.length; _i++) {
var prefix = _a[_i];
this.buildQueryParams(prefix, unusedParams[prefix], add);
}
url = url + '?' + queryParams_1.join('&');
}
Expand Down Expand Up @@ -277,7 +278,7 @@ var Router = /** @class */ (function () {
exports.Router = Router;
exports.Routing = new Router();
exports["default"] = exports.Routing;
return { Router: exports.Router, Routing: exports.Routing };
}));


return { Router: exports.Router, Routing: exports.Routing };
}));
2 changes: 1 addition & 1 deletion Resources/public/js/router.min.js

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