Merge pull request #5230 from mempool/simon/docs-root-network-support

Docs root network support
This commit is contained in:
softsimon 2024-06-28 11:43:05 +09:00 committed by GitHub
commit f02d8e0626
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -72,7 +72,7 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
this.auditEnabled = this.env.AUDIT;
this.network$ = merge(of(''), this.stateService.networkChanged$).pipe(
tap((network: string) => {
if (this.env.BASE_MODULE === 'mempool' && network !== '') {
if (this.env.BASE_MODULE === 'mempool' && network !== '' && this.env.ROOT_NETWORK === '') {
this.baseNetworkUrl = `/${network}`;
} else if (this.env.BASE_MODULE === 'liquid') {
if (!['', 'liquid'].includes(network)) {
@ -195,6 +195,10 @@ export class ApiDocsComponent implements OnInit, AfterViewInit {
}
}
if (network === this.env.ROOT_NETWORK) {
curlNetwork = '';
}
let text = code.codeTemplate.curl;
for (let index = 0; index < curlResponse.length; index++) {
const curlText = curlResponse[index];

View File

@ -284,7 +284,7 @@ yarn add @mempool/liquid.js`;
const headersString = code.headers ? ` -H "${code.headers}"` : ``;
if (this.env.BASE_MODULE === 'mempool') {
if (this.network === 'main' || this.network === '') {
if (this.network === 'main' || this.network === '' || this.network === this.env.ROOT_NETWORK) {
if (this.method === 'POST') {
return `curl${headersString} -X POST -sSLd "${text}"`;
}
@ -296,7 +296,7 @@ yarn add @mempool/liquid.js`;
return `curl${headersString} -sSL "${this.hostname}/${this.network}${text}"`;
} else if (this.env.BASE_MODULE === 'liquid') {
if (this.method === 'POST') {
if (this.network !== 'liquid') {
if (this.network !== 'liquid' || this.network === this.env.ROOT_NETWORK) {
text = text.replace('/api', `/${this.network}/api`);
}
return `curl${headersString} -X POST -sSLd "${text}"`;