Browse Source

Fix Windows slash issue with ChangedFile

Update ChangedFile to clean paths when returning the relative name.

See gh-3082
pull/3096/head
Phillip Webb 11 years ago
parent
commit
4313a43cc8
  1. 7
      spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java

7
spring-boot-developer-tools/src/main/java/org/springframework/boot/developertools/filewatch/ChangedFile.java

@ -19,6 +19,7 @@ package org.springframework.boot.developertools.filewatch; @@ -19,6 +19,7 @@ package org.springframework.boot.developertools.filewatch;
import java.io.File;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* A single file that has changed.
@ -71,8 +72,10 @@ public final class ChangedFile { @@ -71,8 +72,10 @@ public final class ChangedFile {
* @return the relative name
*/
public String getRelativeName() {
String folderName = this.sourceFolder.getAbsoluteFile().getPath();
String fileName = this.file.getAbsoluteFile().getPath();
File folder = this.sourceFolder.getAbsoluteFile();
File file = this.file.getAbsoluteFile();
String folderName = StringUtils.cleanPath(folder.getPath());
String fileName = StringUtils.cleanPath(file.getPath());
Assert.state(fileName.startsWith(folderName), "The file " + fileName
+ " is not contained in the source folder " + folderName);
return fileName.substring(folderName.length() + 1);

Loading…
Cancel
Save