From 2f7cdc5590e5a915191dc88ec315195b5f1befd0 Mon Sep 17 00:00:00 2001 From: shelbert Date: Wed, 26 Jan 2022 12:25:46 +0100 Subject: [PATCH] fix index.html js indentation --- .../ui/AbstractSwaggerIndexTransformer.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java b/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java index e436c7b11..fb399e715 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/ui/AbstractSwaggerIndexTransformer.java @@ -199,21 +199,21 @@ private String addParameter(String html, String key, String value) { */ protected String addCSRF(String html) { StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append("requestInterceptor: (request) => {\n"); - stringBuilder.append("const value = `; ${document.cookie}`;\n"); - stringBuilder.append("const parts = value.split(`; "); - stringBuilder.append(swaggerUiConfig.getCsrf().getCookieName()); - stringBuilder.append("=`);\n"); - stringBuilder.append("const currentURL = new URL(document.URL);\n"); - stringBuilder.append("const requestURL = new URL(request.url, document.location.origin);\n"); - stringBuilder.append("const isSameOrigin = (currentURL.protocol === requestURL.protocol && currentURL.host === requestURL.host);\n"); - stringBuilder.append("if (isSameOrigin && parts.length === 2) "); - stringBuilder.append("request.headers['"); - stringBuilder.append(swaggerUiConfig.getCsrf().getHeaderName()); - stringBuilder.append("'] = parts.pop().split(';').shift();\n"); - stringBuilder.append("return request;\n"); - stringBuilder.append("},\n"); - stringBuilder.append(PRESETS); + stringBuilder.append("requestInterceptor: (request) => {\n"); + stringBuilder.append("\t\t\tconst value = `; ${document.cookie}`;\n"); + stringBuilder.append("\t\t\tconst parts = value.split(`; "); + stringBuilder.append(swaggerUiConfig.getCsrf().getCookieName()); + stringBuilder.append("=`);\n"); + stringBuilder.append("\t\t\tconst currentURL = new URL(document.URL);\n"); + stringBuilder.append("\t\t\tconst requestURL = new URL(request.url, document.location.origin);\n"); + stringBuilder.append("\t\t\tconst isSameOrigin = (currentURL.protocol === requestURL.protocol && currentURL.host === requestURL.host);\n"); + stringBuilder.append("\t\t\tif (isSameOrigin && parts.length === 2) "); + stringBuilder.append("request.headers['"); + stringBuilder.append(swaggerUiConfig.getCsrf().getHeaderName()); + stringBuilder.append("'] = parts.pop().split(';').shift();\n"); + stringBuilder.append("\t\t\treturn request;\n"); + stringBuilder.append("\t\t},\n"); + stringBuilder.append("\t\t" + PRESETS); return html.replace(PRESETS, stringBuilder.toString()); } @@ -226,18 +226,18 @@ protected String addCSRF(String html) { protected String addCSRFLocalStorage(String html) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("requestInterceptor: (request) => {\n"); - stringBuilder.append("const value = window.localStorage.getItem('"); + stringBuilder.append("t\t\tconst value = window.localStorage.getItem('"); stringBuilder.append(swaggerUiConfig.getCsrf().getLocalStorageKey() + "');\n"); - stringBuilder.append("const currentURL = new URL(document.URL);\n"); - stringBuilder.append("const requestURL = new URL(request.url, document.location.origin);\n"); - stringBuilder.append("const isSameOrigin = (currentURL.protocol === requestURL.protocol && currentURL.host === requestURL.host);\n"); - stringBuilder.append("if (isSameOrigin) "); + stringBuilder.append("t\t\tconst currentURL = new URL(document.URL);\n"); + stringBuilder.append("t\t\tconst requestURL = new URL(request.url, document.location.origin);\n"); + stringBuilder.append("t\t\tconst isSameOrigin = (currentURL.protocol === requestURL.protocol && currentURL.host === requestURL.host);\n"); + stringBuilder.append("t\t\tif (isSameOrigin) "); stringBuilder.append("request.headers['"); stringBuilder.append(swaggerUiConfig.getCsrf().getHeaderName()); stringBuilder.append("'] = value;\n"); - stringBuilder.append("return request;\n"); - stringBuilder.append("},\n"); - stringBuilder.append(PRESETS); + stringBuilder.append("t\t\treturn request;\n"); + stringBuilder.append("\t\t},\n"); + stringBuilder.append("\t\t" + PRESETS); return html.replace(PRESETS, stringBuilder.toString()); }