<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>Hi Rich,</div><div><br></div><div>On Nov 14, 2012, at 7:05 PM, Rich Brown &lt;<a href="mailto:richb.hanover@gmail.com">richb.hanover@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">I have been playing with Twisted 12.2.0, and encountered this minor infelicity:<br></blockquote><div><br></div><div>10 points for use of the word "infelicity".</div><br><blockquote type="cite">1) Files not at the root of the web server work as expected:<br><br>a) putChild("foo", File("some-directory")) works as expected - URL is <a href="http://example.com/foo/">http://example.com/foo/</a><br>
<br>b) Navigating to the directory "bar" within "foo" gives a URL of <a href="http://example.com/foo/bar/">http://example.com/foo/bar/</a> as expected.<br></blockquote><div><br></div><div>Glad to hear it.</div><br><blockquote type="cite">2) Files at the root of the web server wind up with an extra "/" in the URL:<br>
<br>a)&nbsp; putChild("", File("some-directory")) yields a URL of <a href="http://example.com//">http://example.com//</a>&nbsp;&nbsp; &lt;-- note double slash<br></blockquote><div><br></div><div>This is not the root of the web server.</div><div><br></div><div>The thing you are calling putChild *on* is the root of the web server. &nbsp;You are placing a <i>directory</i>&nbsp;as the <i>index</i>&nbsp;of another <i>directory.</i>&nbsp; This is obviously a sort of silly thing to do, but it is nevertheless possible.</div><br><blockquote type="cite">b) navigating to the same directory "bar" gives: <a href="http://example.com//bar">http://example.com//bar</a>&nbsp;&nbsp; &lt;-- double-slash again...<br></blockquote><div><br></div>Think of this as ".getChild('').getChild('bar')" rather than "double-slash". &nbsp;Or rather, .getChild(x).getChild(y) where x and y happen to be '' and 'bar' respectively; there just isn't anything special about '' other than it looking funny to humans.</div><div><br><blockquote type="cite">Conclusion:<br><br>I think it would make sense to special the case of the root directory and not output a double "//" in the URL.<br></blockquote><br></div><div>I think the thing to do would be to provide some better debugging / diagnostic / visualization tools to allow people to see what sort of hierarchy they've constructed, since this is in some sense an entirely sensible thing. &nbsp;I was momentarily tempted to say that we should make it an error, but then I realized that while constructing hierarchies this way is perhaps <i>gauche</i>&nbsp;according to the idioms of the web, is is in no way <i>incorrect</i>, and there's no reason to break people's programs for doing it.</div><div><br></div><div>-glyph</div><div><br></div></body></html>