Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is an extra / at the end of the URL. #396

Closed
xianglin2020 opened this issue Dec 14, 2022 · 1 comment
Closed

There is an extra / at the end of the URL. #396

xianglin2020 opened this issue Dec 14, 2022 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@xianglin2020
Copy link

xianglin2020 commented Dec 14, 2022

Your Environment(您的使用环境)

  • smart-doc version: 2.6.3
  • plugin version (e.g. smart-doc-maven-plugin or smart-doc-gradle-plugin): gradle 2.6.3
  • build tool version(maven or gradle): gradle 7.6
  • Spring Boot 3.0.0-SNAPSHOT

Expected Behavior(您期望的结果)

The following code:

@RestController
@RequestMapping("/index")
public class BController {
    /**
     * index-b
     */
    @GetMapping
    public String index() {
        return "b";
    }
}

The expected generated URL is: /index

Current Behavior(当前结果)

The actual generated URL is: /index/.

In Spring Boot 3 (Framework 6.0), /index/ no longer matches /index. ,[Spring-Boot-3.0-Migration-Guide](https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#spring-mvc-and-webflux-url-matching-changes)。This results in a 404 error when debugging on the DEBUG page.

Possible Solution(bug解决建议)

com.power.doc.utils.DocUrlUtil#getMvcUrls() If the URL is an empty string in the method, do not concatenate it, as shown below:

public static String getMvcUrls(String baseServer, String baseUrl, List<String> urls) {
        StringBuilder sb = new StringBuilder();
        List<String> baseUrls = DocUtil.split(baseUrl);
        int size = urls.size();
        int baseSize = baseUrls.size();
        for (int j = 0; j < baseSize; j++) {
            String base = baseUrls.get(j);
            String trimBase = Optional.ofNullable(StringUtil.trimBlank(base)).orElse(StringUtil.EMPTY);
            trimBase = trimBase.replace("[", "").replace("]", "");
            for (int i = 0; i < size; i++) {
                String trimUrl = Optional.ofNullable(StringUtil.trimBlank(urls.get(i))).orElse(StringUtil.EMPTY);
                // String url = baseServer + "/" + trimBase + "/" + trimUrl;
                // Change to the following statement:
                String url = baseServer + "/" + trimBase + (StringUtil.isNotEmpty(trimUrl) ? "/" + trimUrl : "");
                sb.append(UrlUtil.simplifyUrl(url));
                if (i < size - 1) {
                    sb.append(DocGlobalConstants.MULTI_URL_SEPARATOR);
                }
            }
            if (j < baseSize - 1) {
                sb.append(DocGlobalConstants.MULTI_URL_SEPARATOR);
            }
        }

        return sb.toString();
    }

Steps to Reproduce (Bug产生步骤,请尽量提供用例代码)

As above

Context(Bug影响描述)

It currently only affects debugging on the DEBUG page.

@xianglin2020 xianglin2020 added the bug Something isn't working label Dec 14, 2022
@netdied
Copy link
Collaborator

netdied commented Dec 14, 2022

Since the changes have been made, you can directly submit a pull request.
改都改了 可以直接提pr的

shalousun added a commit that referenced this issue Dec 17, 2022
@shalousun shalousun added this to the 2.6.4 milestone Dec 17, 2022
@shalousun shalousun changed the title URL 结尾存在多余 / There is an extra / at the end of the URL. Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants