Skip to content

Commit 84babcb

Browse files
committed
Fix apostrophes in app names (fixes #319) (#327)
1 parent 69f909b commit 84babcb

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

src/dashboard/AppData.react.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
* This source code is licensed under the license found in the LICENSE file in
66
* the root directory of this source tree.
77
*/
8-
import React from 'react';
8+
import React from 'react';
99

1010
import AppSelector from 'dashboard/AppSelector.react';
1111
import AppsManager from 'lib/AppsManager';
12-
import history from 'dashboard/history';
13-
import html from 'lib/htmlString';
14-
import ParseApp from 'lib/ParseApp';
12+
import history from 'dashboard/history';
13+
import html from 'lib/htmlString';
14+
import ParseApp from 'lib/ParseApp';
1515

1616
let AppData = React.createClass({
1717
childContextTypes: {
@@ -22,7 +22,7 @@ let AppData = React.createClass({
2222
getChildContext() {
2323
return {
2424
generatePath: this.generatePath,
25-
currentApp: AppsManager.findAppBySlug(this.props.params.appId)
25+
currentApp: AppsManager.findAppBySlugOrName(this.props.params.appId)
2626
};
2727
},
2828

@@ -34,7 +34,8 @@ let AppData = React.createClass({
3434
if (this.props.params.appId === '_') {
3535
return <AppSelector />;
3636
}
37-
let current = AppsManager.findAppBySlug(this.props.params.appId);
37+
//Find by name to catch edge cases around escaping apostrophes in URLs
38+
let current = AppsManager.findAppBySlugOrName(this.props.params.appId);
3839
if (current) {
3940
current.setParseKeys();
4041
} else {

src/lib/AppsManager.js

+2-12
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,16 @@ const AppsManager = {
2121
return appsStore;
2222
},
2323

24-
findAppBySlug(slug) {
24+
findAppBySlugOrName(slugOrName) {
2525
let apps = this.apps();
2626
for (let i = apps.length; i--;) {
27-
if (apps[i].slug === slug) {
27+
if (apps[i].slug === slugOrName || apps[i].name === slugOrName) {
2828
return apps[i];
2929
}
3030
}
3131
return null;
3232
},
3333

34-
findAppByName(name) {
35-
let apps = this.apps();
36-
for (let i = apps.length; i--;) {
37-
if (apps[i].name === name) {
38-
return apps[i]
39-
}
40-
}
41-
return null;
42-
},
43-
4434
create(name, connectionURL) {
4535
let payload = {
4636
parse_app: { name }

src/lib/ParseApp.js

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export default class ParseApp {
3939
serverInfo,
4040
production,
4141
iconName,
42-
...params,
4342
}) {
4443
this.name = appName;
4544
this.createdAt = created_at ? new Date(created_at) : new Date();

0 commit comments

Comments
 (0)