File tree 1 file changed +9
-5
lines changed
src/librustdoc/html/static/js
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -1828,11 +1828,15 @@ href="https://doc.rust-lang.org/${channel}/rustdoc/read-documentation/search.htm
1828
1828
return ;
1829
1829
}
1830
1830
but . onclick = ( ) => {
1831
- const path = [ ] ;
1832
- onEachLazy ( document . querySelectorAll ( ".rustdoc-breadcrumbs a" ) , a => {
1833
- path . push ( a . textContent ) ;
1834
- } ) ;
1835
- path . push ( document . querySelector ( "title" ) . textContent . split ( " " ) [ 0 ] ) ;
1831
+ // Most page titles are '<Item> in <path::to::module> - Rust', except
1832
+ // modules (which don't have the first part) and keywords/primitives
1833
+ // (which don't have a module path)
1834
+ const title = document . querySelector ( "title" ) . textContent . replace ( " - Rust" , "" ) ;
1835
+ const [ item , module ] = title . split ( " in " ) ;
1836
+ let path = [ item ] ;
1837
+ if ( module !== undefined ) {
1838
+ path . unshift ( module ) ;
1839
+ }
1836
1840
1837
1841
copyContentToClipboard ( path . join ( "::" ) ) ;
1838
1842
copyButtonAnimation ( but ) ;
You can’t perform that action at this time.
0 commit comments