@@ -3,7 +3,7 @@ import Component from '@ember/component';
33import layout from './template' ;
44import { computed } from '@ember/object' ;
55import appFiles from 'ember-cli-addon-docs/app-files' ;
6- import { dasherize } from '@ ember/string ' ;
6+ import addonFiles from 'ember-cli-addon-docs/addon-files ' ;
77import config from 'dummy/config/environment' ;
88import { getOwner } from '@ember/application' ;
99
@@ -23,20 +23,23 @@ export default Component.extend({
2323 editCurrentPageUrl : computed ( 'router.currentRouteName' , function ( ) {
2424 let path = this . get ( 'router.currentRouteName' ) ;
2525 if ( ! path ) {
26- // `routing ` doesn't exist for old ember versions via ember-try
26+ // `router ` doesn't exist for old ember versions via ember-try
2727 return ;
2828 }
29+
2930 path = path . replace ( / \. / g, '/' ) ;
3031
31- if ( path === 'docs/api/class' ) {
32- let params = getOwner ( this ) . lookup ( 'route:application' ) . paramsFor ( 'docs.api.class' ) ;
33- let klass = dasherize ( params . class_id . replace ( / - .+ $ / g, '' ) ) ;
34- let path = `pods/${ path } ` ;
32+ if ( path === 'docs/api/item' ) {
33+ let { path } = getOwner ( this ) . lookup ( 'route:application' ) . paramsFor ( 'docs.api.item' ) ;
34+ let file = addonFiles . find ( f => f . match ( path ) ) ;
3535
36- return `${ packageJson . repository } /edit/master/addon/components/${ klass } /component.js` ;
36+ if ( file ) {
37+ return `${ packageJson . repository } /edit/master/addon/${ file } ` ;
38+ }
3739 } else {
38- let templatePath = `pods/${ path } ` ;
39- let file = appFiles . find ( file => file . match ( `${ templatePath } /template.(hbs|md)` ) ) ;
40+ let file = appFiles
41+ . filter ( file => file . match ( / t e m p l a t e .( h b s | m d ) / ) )
42+ . find ( file => file . match ( path ) ) ;
4043
4144 return `${ packageJson . repository } /edit/master/tests/dummy/app/${ file } ` ;
4245 }
0 commit comments