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

FIXED IE and Chrome download issue when file path is window style #93

Merged
merged 2 commits into from
Aug 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/main/java/hudson/plugins/s3/FingerprintRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ public String getName() {
return artifact.getName();
}

@Exported

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, put empty line between methods.

public String getLink() {
//Chrome and IE convert backslash in the URL into forward slashes, need escape with %5c
return artifact.getName().replace("\\","%5C");
}

@Exported
public String getFingerprint() {
return md5sum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<j:forEach var="e" items="${it.artifacts}">
<tr>
<td>
<a href="download/${e.name}">${h.escape(e.name)}</a>
<a href="download/${e.link}">${h.escape(e.name)}</a>
</td>
<td>
<a href="${rootURL}/fingerprint/${e.fingerprint}/">
Expand Down
24 changes: 24 additions & 0 deletions src/test/java/hudson/plugins/s3/FingerprintRecordTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package hudson.plugins.s3;

import org.junit.Test;

import java.net.URLDecoder;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;

public class FingerprintRecordTest {

@Test
public void testGetLink() throws Exception {
String windowsPath = "path\\to\\windows\\test.txt";
FingerprintRecord windowsRecord = new FingerprintRecord(true, "test", windowsPath, "us-eat-1", "xxxx");
String link = windowsRecord.getLink();
String linkDecoded = URLDecoder.decode(link, "utf-8");
assertNotEquals("link is encoded", windowsPath, link);
assertEquals("should match file name", windowsPath, linkDecoded);
String unixPath = "/path/tmp/abc";
FingerprintRecord unixRecord = new FingerprintRecord(true, "test", unixPath, "us-eat-1", "xxxx");
assertEquals("should match file name", unixPath, unixRecord.getLink());
}
}