Node.js based forum software built for the modern web
startsWith
Barış Soner Uşaklı925b12ca2217
diff --git a/public/src/ajaxify.js b/public/src/ajaxify.jsindex 9f06d03cb3..57defca278 100644--- a/public/src/ajaxify.js+++ b/public/src/ajaxify.js@@ -70,7 +70,7 @@ $(document).ready(function() {ajaxify.handleACPRedirect = function(url) {// If ajaxifying into an admin route from regular site, do a cold load.url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));- if (url.indexOf('admin') === 0 && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0) {+ if (url.startsWith('admin') && window.location.pathname.indexOf(RELATIVE_PATH + '/admin') !== 0) {window.open(RELATIVE_PATH + '/' + url, '_blank');return true;}@@ -79,7 +79,7 @@ $(document).ready(function() {ajaxify.handleNonAPIRoutes = function(url) {url = ajaxify.removeRelativePath(url.replace(/\/$/, ''));- if (url.indexOf('uploads') === 0) {+ if (url.startsWith('uploads')) {window.open(RELATIVE_PATH + '/' + url, '_blank');return true;}@@ -168,7 +168,7 @@ $(document).ready(function() {};ajaxify.removeRelativePath = function(url) {- if (url.indexOf(RELATIVE_PATH.slice(1)) === 0) {+ if (url.startsWith(RELATIVE_PATH.slice(1))) {url = url.slice(RELATIVE_PATH.length);}return url;diff --git a/public/src/client/category.js b/public/src/client/category.jsindex c74141feec..ec667a652f 100644--- a/public/src/client/category.js+++ b/public/src/client/category.js@@ -92,7 +92,7 @@ define('forum/category', [};$(window).on('action:popstate', function(ev, data) {- if (data.url.indexOf('category/') === 0) {+ if (data.url.startsWith('category/')) {var cid = data.url.match(/^category\/(\d+)/);if (cid && cid[1]) {cid = cid[1];diff --git a/public/src/client/users.js b/public/src/client/users.jsindex 3e794a008a..11f1deb7bb 100644--- a/public/src/client/users.js+++ b/public/src/client/users.js@@ -171,7 +171,7 @@ define('forum/users', ['translator'], function(translator) {function onUserStatusChange(data) {var section = getActiveSection();- if((section.indexOf('online') === 0 || section.indexOf('users') === 0)) {+ if ((section.startsWith('online') || section.startsWith('users'))) {updateUser(data);}}diff --git a/src/routes/index.js b/src/routes/index.jsindex 5efca3f067..862964dfbe 100644--- a/src/routes/index.js+++ b/src/routes/index.js@@ -152,7 +152,7 @@ module.exports = function(app, middleware) {if (req.user || parseInt(meta.config.privateUploads, 10) !== 1) {return next();}- if (req.path.indexOf('/uploads/files') === 0) {+ if (req.path.startsWith('/uploads/files')) {return res.status(403).json('not-allowed');}next();