@@ -188,27 +188,35 @@ module Routing {
188
188
)
189
189
}
190
190
191
- /**
192
- * Gets the path prefix needed to reach this node from the given ancestor, that is, the concatenation
193
- * of all relative paths between this node and the ancestor.
194
- *
195
- * To restrict the size of the predicate, this is only available for the ancestors that are "fork" nodes,
196
- * that is, a node that has siblings (i.e. multiple children).
197
- */
198
- private string getPathFromFork ( Node fork ) {
191
+ private string getPathFromForkInternal ( Node fork ) {
199
192
this .isFork ( ) and
200
193
this = fork and
201
194
result = ""
202
195
or
203
196
exists ( Node parent | parent = this .getParent ( ) |
204
197
not exists ( parent .getRelativePath ( ) ) and
205
- result = parent .getPathFromFork ( fork )
198
+ result = parent .getPathFromForkInternal ( fork )
206
199
or
207
- result = parent .getPathFromFork ( fork ) + parent .getRelativePath ( ) and
200
+ result = parent .getPathFromForkInternal ( fork ) + parent .getRelativePath ( ) and
208
201
result .length ( ) < 100
209
202
)
210
203
}
211
204
205
+ /**
206
+ * Gets the path prefix needed to reach this node from the given ancestor, that is, the concatenation
207
+ * of all relative paths between this node and the ancestor.
208
+ *
209
+ * To restrict the size of the predicate, this is only available for the ancestors that are "fork" nodes,
210
+ * that is, a node that has siblings (i.e. multiple children).
211
+ * And only a single (shortest) path is returned, even if there are multiple paths
212
+ * leading to this node.
213
+ */
214
+ pragma [ nomagic]
215
+ private string getPathFromFork ( Node fork ) {
216
+ result =
217
+ min ( string res | res = this .getPathFromForkInternal ( fork ) | res order by res .length ( ) , res )
218
+ }
219
+
212
220
/**
213
221
* Gets an HTTP method required to reach this node from the given ancestor, or `*` if any method
214
222
* can be used.
0 commit comments