File tree Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Expand file tree Collapse file tree 4 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 1
1
<div ...attributes>
2
2
<h3 data-test-title>{{ @title }} </h3 >
3
3
<div local-class =" content" >
4
- {{ #if this.isGitHub }}
4
+ {{ #if this.isDocsRs }}
5
+ {{ svg-jar " docs-rs" local-class =" icon" data-test-icon =" docs-rs" }}
6
+ {{ else if this.isGitHub}}
5
7
{{ svg-jar " GitHub-Mark" local-class =" icon" data-test-icon =" github" }}
6
8
{{ else }}
7
9
{{ svg-jar " link" local-class =" icon" data-test-icon =" link" }}
Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ export default class CrateSidebarLink extends Component {
13
13
return url ;
14
14
}
15
15
16
+ get isDocsRs ( ) {
17
+ return this . text . startsWith ( 'docs.rs/' ) ;
18
+ }
19
+
16
20
get isGitHub ( ) {
17
21
return this . text . startsWith ( 'github.com/' ) ;
18
22
}
Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ module('Component | CrateSidebar::Link', function (hooks) {
24
24
. hasText ( 'github.com/rust-lang/crates.io' ) ;
25
25
} ) ;
26
26
27
+ test ( 'renders docs.rs icon for docs.rs links' , async function ( assert ) {
28
+ await render ( hbs `<CrateSidebar::Link @url="https://docs.rs/tracing" />` ) ;
29
+ assert . dom ( '[data-test-icon]' ) . exists ( { count : 1 } ) . hasAttribute ( 'data-test-icon' , 'docs-rs' ) ;
30
+ assert . dom ( '[data-test-link]' ) . hasAttribute ( 'href' , 'https://docs.rs/tracing' ) . hasText ( 'docs.rs/tracing' ) ;
31
+ } ) ;
32
+
27
33
test ( 'does not shorten HTTP links' , async function ( assert ) {
28
34
await render ( hbs `<CrateSidebar::Link @url="http://www.rust-lang.org" />` ) ;
29
35
assert . dom ( '[data-test-link]' ) . hasAttribute ( 'href' , 'http://www.rust-lang.org' ) . hasText ( 'http://www.rust-lang.org' ) ;
You can’t perform that action at this time.
0 commit comments