Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 4c59d94

Browse files
authored
Fix for #661, using File.separatorChar (#666)
1 parent 296aa97 commit 4c59d94

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/main/java/org/raml/parser/tagresolver/ContextPath.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static org.raml.parser.tagresolver.IncludeResolver.INCLUDE_APPLIED_TAG;
1919

20+
import java.io.File;
2021
import java.util.ArrayDeque;
2122
import java.util.Deque;
2223

@@ -70,7 +71,7 @@ public static String resolveAbsolutePath(String relativeFile, String parentPath)
7071

7172
public String resolveAbsolutePath(String relativeFile)
7273
{
73-
return resolveAbsolutePath(relativeFile, getPartentPath());
74+
return resolveAbsolutePath(relativeFile, getParentPath());
7475
}
7576

7677
/**
@@ -91,25 +92,25 @@ public String resolveRelativePath(Tag tag)
9192
{
9293
throw new IllegalArgumentException("Tag must be an include applied");
9394
}
94-
String partentPath = getPartentPath();
95+
String parentPath = getParentPath();
9596
String includePath = new IncludeInfo(tag).getIncludeName();
9697

97-
if (includePath.startsWith(partentPath))
98+
if (includePath.startsWith(parentPath))
9899
{
99-
includePath = includePath.substring(partentPath.length());
100+
includePath = includePath.substring(parentPath.length());
100101
}
101102
return includePath;
102103
}
103104

104-
public static String getPartentPath(String path)
105+
public static String getParentPath(String path)
105106
{
106-
int idx = path.lastIndexOf("/") + 1;
107+
int idx = path.lastIndexOf(File.separatorChar) + 1;
107108
return path.substring(0, idx);
108109
}
109110

110-
private String getPartentPath()
111+
private String getParentPath()
111112
{
112-
return getPartentPath(includeStack.peek().getIncludeName());
113+
return getParentPath(includeStack.peek().getIncludeName());
113114
}
114115

115116
public IncludeInfo peek()
@@ -129,7 +130,7 @@ public void push(IncludeInfo includeInfo)
129130

130131
public void push(ScalarNode node)
131132
{
132-
push(new IncludeInfo(node, getPartentPath()));
133+
push(new IncludeInfo(node, getParentPath()));
133134
}
134135

135136
public void push(Tag tag)

src/main/java/org/raml/parser/visitor/TemplateResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ private Node resolveInclude(Node node, Tag tag)
214214
// parent include applied tag path
215215
ScalarNode scalarNode = (ScalarNode) node;
216216
String parentPath = includeResolver.getContextPath().resolveRelativePath(tag);
217-
String includePathRecalculated = ContextPath.getPartentPath(parentPath) + scalarNode.getValue();
217+
String includePathRecalculated = ContextPath.getParentPath(parentPath) + scalarNode.getValue();
218218
node = new ScalarNode(scalarNode.getTag(), includePathRecalculated, node.getStartMark(), node.getEndMark(), scalarNode.getStyle());
219219
}
220220
return includeResolver.resolve(node, resourceLoader, nodeNandler);

0 commit comments

Comments
 (0)