Skip to content

Commit

Permalink
Fix apostrophes in app names (fixes parse-community#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
drew-gross committed May 6, 2016
1 parent 45b2b33 commit 19242e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
13 changes: 7 additions & 6 deletions src/dashboard/AppData.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
* This source code is licensed under the license found in the LICENSE file in
* the root directory of this source tree.
*/
import React from 'react';
import React from 'react';

import AppSelector from 'dashboard/AppSelector.react';
import AppsManager from 'lib/AppsManager';
import history from 'dashboard/history';
import html from 'lib/htmlString';
import ParseApp from 'lib/ParseApp';
import history from 'dashboard/history';
import html from 'lib/htmlString';
import ParseApp from 'lib/ParseApp';

let AppData = React.createClass({
childContextTypes: {
Expand All @@ -22,7 +22,7 @@ let AppData = React.createClass({
getChildContext() {
return {
generatePath: this.generatePath,
currentApp: AppsManager.findAppBySlug(this.props.params.appId)
currentApp: AppsManager.findAppBySlugOrName(this.props.params.appId)
};
},

Expand All @@ -34,7 +34,8 @@ let AppData = React.createClass({
if (this.props.params.appId === '_') {
return <AppSelector />;
}
let current = AppsManager.findAppBySlug(this.props.params.appId);
//Find by name to catch edge cases around escaping apostrophes in URLs
let current = AppsManager.findAppBySlugOrName(this.props.params.appId);
if (current) {
current.setParseKeys();
} else {
Expand Down
14 changes: 2 additions & 12 deletions src/lib/AppsManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,16 @@ const AppsManager = {
return appsStore;
},

findAppBySlug(slug) {
findAppBySlugOrName(slugOrName) {
let apps = this.apps();
for (let i = apps.length; i--;) {
if (apps[i].slug === slug) {
if (apps[i].slug === slugOrName || apps[i].name === slugOrName) {
return apps[i];
}
}
return null;
},

findAppByName(name) {
let apps = this.apps();
for (let i = apps.length; i--;) {
if (apps[i].name === name) {
return apps[i]
}
}
return null;
},

create(name, connectionURL) {
let payload = {
parse_app: { name }
Expand Down
1 change: 0 additions & 1 deletion src/lib/ParseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default class ParseApp {
serverInfo,
production,
iconName,
...params,
}) {
this.name = appName;
this.createdAt = created_at ? new Date(created_at) : new Date();
Expand Down

0 comments on commit 19242e7

Please sign in to comment.