Skip to content

Commit 242abbc

Browse files
committed
Merge branch 'hotfix/19.1.2'
2 parents 0492b61 + 16ddf0e commit 242abbc

File tree

9 files changed

+69
-59
lines changed

9 files changed

+69
-59
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [19.1.2] - 2019-02-12
8+
### Fixed
9+
- Utils:
10+
- `transitionTargetURL` - clean guid routing path components from URLs
11+
### Added:
12+
- Route Flags:
13+
- `guid-node.index` -> `ember_project_detail_page`
14+
- `guid-registration.index` -> `ember_old_registration_detail_page`
15+
716
## [19.1.1] - 2019-02-11
817
### Fixed
918
- Router:

app/locations/guid-mixin.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
import Mixin from '@ember/object/mixin';
22

3-
export default Mixin.create({
4-
pattern: /(?:^|\/)--[^/]+/g,
5-
6-
cleanURL(url: string) {
7-
return url.replace(this.pattern, '');
8-
},
3+
import cleanURL from 'ember-osf-web/utils/clean-url';
94

5+
export default Mixin.create({
106
setURL(url: string) {
11-
return this._super(this.cleanURL(url));
7+
return this._super(cleanURL(url));
128
},
139

1410
replaceURL(url: string) {
15-
return this._super(this.cleanURL(url));
11+
return this._super(cleanURL(url));
1612
},
1713

1814
formatURL(url: string): string {
19-
return this._super(this.cleanURL(url));
15+
return this._super(cleanURL(url));
2016
},
2117
});

app/utils/clean-url.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Remove the --guidtype portions of a URL that are only used for guid routing
3+
* and should never appear in a real URL.
4+
*/
5+
export default function cleanURL(url: string) {
6+
return url.replace(/(?:^|\/)--[^/]+/g, '');
7+
}

app/utils/transition-target-url.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Transition from '@ember/routing/-private/transition';
22

3+
import cleanURL from 'ember-osf-web/utils/clean-url';
4+
35
/**
46
* Get the URL (path and query string) that the given transition will resolve to,
57
* using the given router.
@@ -10,9 +12,11 @@ export default function transitionTargetURL(
1012
const params = Object.values(transition.params).filter(
1113
param => Object.values(param).length,
1214
);
13-
return transition.router.generate(
14-
transition.targetName,
15-
...params,
16-
{ queryParams: transition.queryParams },
15+
return cleanURL(
16+
transition.router.generate(
17+
transition.targetName,
18+
...params,
19+
{ queryParams: transition.queryParams },
20+
),
1721
);
1822
}

config/environment.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ module.exports = function(environment) {
215215
},
216216
featureFlagNames: {
217217
routes: {
218+
'guid-node.index': 'ember_project_detail_page',
219+
'guid-registration.index': 'ember_old_registration_detail_page',
218220
settings: 'ember_user_settings_profile_page',
219221
'settings.profile': 'ember_user_settings_profile_page',
220222
'settings.profile.education': 'ember_user_settings_profile_page',

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-osf-web",
3-
"version": "19.1.1",
3+
"version": "19.1.2",
44
"description": "Ember front-end for the Open Science Framework",
55
"license": "Apache-2.0",
66
"author": "Center for Open Science <support@cos.io>",

tests/unit/locations/auto-guid-test.ts

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,10 @@ import GuidAutoLocation from 'ember-osf-web/locations/auto';
22
import { setupTest } from 'ember-qunit';
33
import { module, test } from 'qunit';
44

5-
const TEST_CASES = [{
6-
input: '/--user/abcd/',
7-
output: '/abcd/',
8-
}, {
9-
input: '/--user/abcd',
10-
output: '/abcd',
11-
}, {
12-
input: '/--user/--nested/abcd/',
13-
output: '/abcd/',
14-
}, {
15-
input: '/--registries-engine/overview/',
16-
output: '/overview/',
17-
}, {
18-
input: '/collections/--something--else/here/',
19-
output: '/collections/here/',
20-
}, {
21-
input: '/--registries/',
22-
output: '/',
23-
}, {
24-
input: '/AttheEnd/--registries/',
25-
output: '/AttheEnd/',
26-
}, {
27-
input: '/AttheEnd/--registries',
28-
output: '/AttheEnd',
29-
}, {
30-
input: '/normal--url/',
31-
output: '/normal--url/',
32-
}];
33-
345
module('Unit | Location | guid-auto ', hooks => {
356
setupTest(hooks);
367

378
test('it exists', function(assert) {
389
assert.ok(this.owner.lookup('location:auto') instanceof GuidAutoLocation);
3910
});
40-
41-
test('cleanURL', function(assert) {
42-
const location = this.owner.lookup('location:auto') as GuidAutoLocation;
43-
44-
for (const testCase of TEST_CASES) {
45-
assert.equal(location.cleanURL(testCase.input), testCase.output);
46-
}
47-
});
4811
});

tests/unit/locations/none-guid-test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ module('Unit | Location | none-auto ', hooks => {
3535
assert.ok(this.owner.lookup('location:none') instanceof GuidNoneLocation);
3636
});
3737

38-
test('cleanURL', function(assert) {
39-
const location = this.owner.lookup('location:none') as GuidNoneLocation;
40-
41-
for (const testCase of TEST_CASES) {
42-
assert.equal(location.cleanURL(testCase.input), testCase.output);
43-
}
44-
});
45-
4638
test('setURL does not clean', function(assert) {
4739
const location = this.owner.lookup('location:none') as GuidNoneLocation;
4840

tests/unit/utils/clean-url-test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { module, test } from 'qunit';
2+
3+
import cleanURL from 'ember-osf-web/utils/clean-url';
4+
5+
const TEST_CASES = [{
6+
input: '/--user/abcd',
7+
output: '/abcd',
8+
}, {
9+
input: '/--user/--nested/abcd',
10+
output: '/abcd',
11+
}, {
12+
input: '/--registries-engine/overview',
13+
output: '/overview',
14+
}, {
15+
input: '/collections/--something--else/here',
16+
output: '/collections/here',
17+
}, {
18+
input: '/--registries',
19+
output: '',
20+
}, {
21+
input: '/AttheEnd/--registries',
22+
output: '/AttheEnd',
23+
}, {
24+
input: '/normal--url',
25+
output: '/normal--url',
26+
}];
27+
28+
module('Unit | Utility | cleanURL', () => {
29+
test('cleanURL cleans urls', assert => {
30+
assert.expect(TEST_CASES.length * 2);
31+
32+
for (const testCase of TEST_CASES) {
33+
assert.equal(cleanURL(testCase.input), testCase.output);
34+
assert.equal(cleanURL(`${testCase.input}/`), `${testCase.output}/`);
35+
}
36+
});
37+
});

0 commit comments

Comments
 (0)