@@ -7,14 +7,12 @@ export function injectHyperlinks(code: string) {
7
7
while ( match != null ) {
8
8
const [ line , libraryPrefix , libraryPath ] = match ;
9
9
if ( line !== undefined && libraryPrefix !== undefined && libraryPath !== undefined ) {
10
- const githubPrefix = `https://github.com/OpenZeppelin/cairo-contracts/blob/${ contractsVersionTag } /src /` ;
10
+ const githubPrefix = `https://github.com/OpenZeppelin/cairo-contracts/blob/${ contractsVersionTag } /packages /` ;
11
11
12
12
let libraryPathSegments = libraryPath . split ( '::' ) ;
13
+ libraryPathSegments . splice ( 1 , 0 , 'src' ) ;
13
14
14
- // Remove the component name
15
- if ( libraryPathSegments . length > 0 && libraryPathSegments [ libraryPathSegments . length - 1 ] !== 'interface' ) {
16
- libraryPathSegments . pop ( ) ;
17
- }
15
+ removeComponentName ( libraryPathSegments ) ;
18
16
19
17
if ( libraryPathSegments !== undefined && libraryPathSegments . length > 0 ) {
20
18
const replacedImportLine = `use<\/span> <a class="import-link" href='${ githubPrefix } ${ libraryPathSegments . join ( '/' ) } .cairo' target='_blank' rel='noopener noreferrer'>${ libraryPrefix } ::${ libraryPath } </a>;` ;
@@ -24,4 +22,14 @@ export function injectHyperlinks(code: string) {
24
22
match = importRegex . exec ( code ) ;
25
23
}
26
24
return result ;
27
- }
25
+ }
26
+
27
+ function removeComponentName ( libraryPathSegments : Array < string > ) {
28
+ const lastItem = libraryPathSegments [ libraryPathSegments . length - 1 ] ;
29
+ if ( lastItem === 'UpgradeableComponent' ) {
30
+ // Replace component name with 'upgradeable'
31
+ libraryPathSegments . splice ( - 1 , 1 , 'upgradeable' ) ;
32
+ } else {
33
+ libraryPathSegments . pop ( ) ;
34
+ }
35
+ }
0 commit comments