File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
src/librustdoc/html/static/js Expand file tree Collapse file tree 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
18281828 return ;
18291829 }
18301830 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+ }
18361840
18371841 copyContentToClipboard ( path . join ( "::" ) ) ;
18381842 copyButtonAnimation ( but ) ;
You can’t perform that action at this time.
0 commit comments