Author: chris.laprun(a)jboss.com
Date: 2010-03-08 20:57:50 -0500 (Mon, 08 Mar 2010)
New Revision: 2043
Modified:
components/common/trunk/common/src/main/java/org/gatein/common/net/URLTools.java
components/common/trunk/common/src/test/java/org/gatein/common/net/URLToolsTestCase.java
Log:
- Make sure that getExtensionOrNullFrom gets the real extension.
Modified:
components/common/trunk/common/src/main/java/org/gatein/common/net/URLTools.java
===================================================================
---
components/common/trunk/common/src/main/java/org/gatein/common/net/URLTools.java 2010-03-09
01:51:35 UTC (rev 2042)
+++
components/common/trunk/common/src/main/java/org/gatein/common/net/URLTools.java 2010-03-09
01:57:50 UTC (rev 2043)
@@ -99,7 +99,7 @@
return null;
}
- int periodIndex = file.indexOf('.');
+ int periodIndex = file.lastIndexOf('.');
if (periodIndex != -1)
{
String extension = file.substring(periodIndex + 1);
Modified:
components/common/trunk/common/src/test/java/org/gatein/common/net/URLToolsTestCase.java
===================================================================
---
components/common/trunk/common/src/test/java/org/gatein/common/net/URLToolsTestCase.java 2010-03-09
01:51:35 UTC (rev 2042)
+++
components/common/trunk/common/src/test/java/org/gatein/common/net/URLToolsTestCase.java 2010-03-09
01:57:50 UTC (rev 2043)
@@ -286,5 +286,11 @@
url = new URL("http://localhost:8080/portal/file.");
assertNull(URLTools.getFileExtensionOrNullFrom(url));
+
+ url = new URL("http://localhost:8080/portal/file.txt?blah");
+ assertEquals("txt", URLTools.getFileExtensionOrNullFrom(url));
+
+ url = new URL("http://localhost:8080/portal/file.txt.xml?blah");
+ assertEquals("xml", URLTools.getFileExtensionOrNullFrom(url));
}
}