Stephen McKamey avatar Stephen McKamey committed 5f9502c

improving detection of default doc scenarios

Comments (0)

Files changed (4)

duel-staticapps-maven-plugin/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-staticapps-maven-plugin</artifactId>
-	<version>0.9.1</version>
+	<version>0.9.2</version>
 	<packaging>maven-plugin</packaging>
 
 	<name>DUEL Static Apps Maven Plugin</name>

duel-staticapps/pom.xml

 
 	<groupId>org.duelengine</groupId>
 	<artifactId>duel-staticapps</artifactId>
-	<version>0.9.1</version>
+	<version>0.9.2</version>
 	<packaging>jar</packaging>
 
 	<name>DUEL Static Apps</name>

duel-staticapps/src/main/java/org/duelengine/duel/staticapps/RoutingServlet.java

 			log.info("routing: "+servletPath);
 
 		} else {
-			if (servletPath.endsWith("/")) {
+			String aliasedPath = servletPath;
+
+			if ("".equals(FileUtil.getExtension(aliasedPath))) {
 				// continue to attempt to resolve with default document
-				page = config.views().get(servletPath.substring(1)+DEFAULT_DOC);
+				if (aliasedPath.endsWith("/")) {
+					aliasedPath += '/';
+				}
+				aliasedPath += DEFAULT_DOC;
+				page = config.views().get(aliasedPath.substring(1));
 			}
+
 			if (page != null) {
-				log.info("routing: "+servletPath+" (as "+servletPath+DEFAULT_DOC+")");
+				log.info("routing: "+servletPath+" (as "+aliasedPath+")");
 
 			} else {
 				// continue to attempt to resolve with catch-all
-				String ext = servletPath.endsWith("/") ? FileUtil.getExtension(DEFAULT_DOC) : FileUtil.getExtension(servletPath);
+				String ext = FileUtil.getExtension(aliasedPath);
 				page = config.views().get("*"+ext);
 				if (page != null) {
 					log.info("routing: "+servletPath+" (as *"+ext+")");

duel-staticapps/src/main/java/org/duelengine/duel/utils/FileUtil.java

 	
 	public static String getExtension(String name) {
 		int dot = name.lastIndexOf('.');
-		if (dot < 0) {
+		if (dot < 0 || dot < name.lastIndexOf('/')) {
 			return "";
 		}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.