@@ -11,15 +11,15 @@ function removeHomeElement() {
1111 if ( homeElementToRemove ) homeElementToRemove . remove ( ) ;
1212}
1313
14- function renderDocsPage ( contentDiv ) {
14+ function renderDocsPage ( contentDiv , suppressWarning = false ) {
1515 if ( window . location . pathname . toLowerCase ( ) !== '/docs' ) return ;
1616
1717 contentDiv . innerHTML = '' ;
1818 contentDiv . style . position = 'relative' ;
1919 contentDiv . style . backgroundColor = 'var(--rovalra-container-background-color)' ;
2020 contentDiv . style . minHeight = 'calc(100vh - 60px)' ;
2121
22- if ( ! sessionStorage . getItem ( 'rovalra_api_docs_warning' ) ) {
22+ if ( ! suppressWarning ) {
2323 const confirmBtn = document . createElement ( 'button' ) ;
2424 confirmBtn . className = 'btn-primary-md' ;
2525 confirmBtn . textContent = 'I Understand' ;
@@ -38,7 +38,6 @@ function renderDocsPage(contentDiv) {
3838 } ) ;
3939
4040 confirmBtn . onclick = ( ) => {
41- sessionStorage . setItem ( 'rovalra_api_docs_warning' , 'true' ) ;
4241 close ( ) ;
4342 } ;
4443 }
@@ -88,7 +87,7 @@ function renderDocsPage(contentDiv) {
8887 clearBtn . style . cursor = 'pointer' ;
8988 clearBtn . onclick = ( ) => {
9089 chrome . storage . local . remove ( CAPTURED_APIS_KEY , ( ) => {
91- renderDocsPage ( contentDiv ) ;
90+ renderDocsPage ( contentDiv , true ) ;
9291 } ) ;
9392 } ;
9493
@@ -138,7 +137,35 @@ function renderDocsPage(contentDiv) {
138137
139138 const renderEndpoints = ( subdomain , filter = '' ) => {
140139 endpointsContainer . innerHTML = '' ;
141- const endpoints = data [ subdomain ] ;
140+ const rawEndpoints = data [ subdomain ] ;
141+ const endpoints = { } ;
142+
143+ Object . keys ( rawEndpoints ) . forEach ( rawPath => {
144+ const normalizedPath = rawPath
145+ . split ( '?' ) [ 0 ]
146+ . split ( '/' )
147+ . map ( segment => {
148+ if ( / ^ \d + $ / . test ( segment ) ) return '{id}' ;
149+ if ( / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 4 } - [ 0 - 9 a - f ] { 12 } $ / i. test ( segment ) ) return '{uuid}' ;
150+ return segment ;
151+ } )
152+ . join ( '/' ) ;
153+
154+ if ( ! endpoints [ normalizedPath ] ) {
155+ endpoints [ normalizedPath ] = { } ;
156+ }
157+
158+ const methods = rawEndpoints [ rawPath ] ;
159+ Object . keys ( methods ) . forEach ( method => {
160+ if ( ! endpoints [ normalizedPath ] [ method ] ) {
161+ endpoints [ normalizedPath ] [ method ] = {
162+ ...methods [ method ] ,
163+ exampleEndpoint : rawPath
164+ } ;
165+ }
166+ } ) ;
167+ } ) ;
168+
142169 let endpointKeys = Object . keys ( endpoints ) . sort ( ) ;
143170 if ( filter ) {
144171 const lowerFilter = filter . toLowerCase ( ) ;
0 commit comments