File tree Expand file tree Collapse file tree 1 file changed +14
-18
lines changed
docs/dokka-presets/scripts Expand file tree Collapse file tree 1 file changed +14
-18
lines changed Original file line number Diff line number Diff line change 55 * https://sdk.amazonaws.com/kotlin/api/latest/index.html -> index.html
66 * https://sdk.amazonaws.com/kotlin/api/latest/s3/index.html -> s3
77 * https://sdk.amazonaws.com/kotlin/api/latest/s3/aws.sdk.kotlin.services.s3/index.html -> s3
8+ * https://sdk.amazonaws.com/kotlin/api/1.4.109/s3/index.html -> s3
89 */
910function extractModulePath ( href ) {
1011 try {
11- const url = new URL ( href , window . location . origin ) ;
12- const pathSegments = url . pathname . split ( '/' ) . filter ( Boolean ) ;
13-
14- var moduleIndex = - 1 ;
15-
16- for ( let i = 1 ; i < pathSegments . length ; i ++ ) {
17- if ( pathSegments [ i ] . includes ( '.' ) ) {
18- moduleIndex = i - 1 ;
19- break ;
20- }
21- }
22-
23- if ( moduleIndex === - 1 ) {
24- return "index.html" ;
25- } else {
26- return pathSegments . slice ( 0 , moduleIndex + 1 ) . join ( "/" ) ;
27- }
28- } catch ( error ) {
12+ const segments = new URL ( href , window . location . origin )
13+ . pathname
14+ . split ( '/' ) // break the path
15+ . filter ( Boolean ) ; // drop empty parts
16+
17+ // the URL pattern is always ".../kotlin/api/<version>/..."
18+ const apiPos = segments . indexOf ( 'api' ) ;
19+ if ( apiPos === - 1 ) return null ;
20+
21+ // segment after "api" is the version ("latest", "1.4.109", etc.)
22+ // segment after _that_ is the module name (or "index.html" if we're at the root)
23+ return segments [ apiPos + 2 ] ?? 'index.html' ;
24+ } catch {
2925 return null ;
3026 }
3127}
You can’t perform that action at this time.
0 commit comments