|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2022 the original author or authors. |
| 2 | + * Copyright 2012-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -108,18 +108,13 @@ protected File getPortFile(ApplicationContext applicationContext) {
|
108 | 108 | if (!StringUtils.hasLength(namespace)) {
|
109 | 109 | return this.file;
|
110 | 110 | }
|
111 |
| - String name = this.file.getName(); |
112 |
| - String extension = StringUtils.getFilenameExtension(name); |
113 |
| - |
114 |
| - StringBuilder builder = new StringBuilder(name); |
115 |
| - |
116 |
| - String suffix = "-" + (isUpperCase(name) ? namespace.toUpperCase(Locale.ENGLISH) : namespace.toLowerCase(Locale.ENGLISH)); |
117 |
| - if (StringUtils.hasLength(extension)) |
118 |
| - builder.insert(name.lastIndexOf(extension) - 1, suffix); |
119 |
| - else |
120 |
| - builder.append(suffix); |
121 |
| - |
122 |
| - return new File(this.file.getParentFile(), builder.toString()); |
| 111 | + String filename = this.file.getName(); |
| 112 | + String extension = StringUtils.getFilenameExtension(filename); |
| 113 | + String filenameWithoutExtension = filename.substring(0, filename.length() - extension.length() - 1); |
| 114 | + String suffix = (!isUpperCase(filename)) ? namespace.toLowerCase(Locale.ENGLISH) |
| 115 | + : namespace.toUpperCase(Locale.ENGLISH); |
| 116 | + return new File(this.file.getParentFile(), |
| 117 | + filenameWithoutExtension + "-" + suffix + ((!StringUtils.hasLength(extension)) ? "" : "." + extension)); |
123 | 118 | }
|
124 | 119 |
|
125 | 120 | private String getServerNamespace(ApplicationContext applicationContext) {
|
|
0 commit comments