Skip to content

Commit

Permalink
🐛 Fix ../ in paths displaying incorrectly
Browse files Browse the repository at this point in the history
Fixes #19
  • Loading branch information
Komposten committed Jul 15, 2019
1 parent 86f2d84 commit 5144ba6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/main/java/komposten/vivaldi/ui/InstructionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,21 @@ private Instruction fixInstructionPaths(Instruction original)
String result = prefix + dir;

int navUpIndex;
while ((navUpIndex = result.indexOf("../")) != -1)
int startIndex = 0;
while ((navUpIndex = result.indexOf("../", startIndex)) != -1)
{
int previousSlash = result.lastIndexOf('/', navUpIndex);

if (previousSlash != -1)
int previousSlash = result.lastIndexOf('/', navUpIndex-2);

if (previousSlash != -1 && previousSlash >= startIndex)
{
result = result.substring(0, previousSlash)
+ result.substring(navUpIndex + 2);
startIndex = 0;
}
else
{
startIndex = navUpIndex+1;
}
}

return new Instruction(src, result, original.excludeFromBrowserHtml);
Expand Down

0 comments on commit 5144ba6

Please sign in to comment.