[Zope-CMF] Re: [CMF-checkins] link object / CMF 1.3b2

Florent Guillaume fg@nuxeo.com
Mon, 1 Jul 2002 16:27:16 +0000 (UTC)


Argh, mailto:, you're right.
My testcases are now as follows.
Really, the best thing to do is to not touch the URL in practically all
cases. I think.

    def test_fixupMissingScheme(self):
        table = {
            'http://foo.com':      'http://foo.com',
            '//bar.com':           'http://bar.com',
            }
        self.canonTest(table)

    def test_keepRelativeUrl(self):
        table = {
            'baz.com':             'baz.com',
            'baz2.com/index.html': 'baz2.com/index.html',
            '/huh/zoinx.html':     '/huh/zoinx.html',
            'hmmm.com/lol.txt':    'hmmm.com/lol.txt',
            }
        self.canonTest(table)

    def test_trailingSlash(self):
        table = {
            'http://foo.com/bar/': 'http://foo.com/bar/',
            'baz.com/':            'baz.com/',
            '/baz.org/zoinx/':     '/baz.org/zoinx/',
            }
        self.canonTest(table)

    def test_otherScheme(self):
        table = {
            'mailto:user@foo.com':      'mailto:user@foo.com',
            'https://bank.com/account': 'https://bank.com/account',
            }
        self.canonTest(table)

Florent


Yuppie  <schubbe@web.de> wrote:
> Hi!
> 
> Florent Guillaume wrote:
> > Ok, I reread RFC1808 and you're right that I don't handle relative URLs
> > correctly. I'll re-change that.
> 
> Some more thoughts about test cases. Perhaps they'll help you to 
> re-change that.
> 
> 1) I think the basic requirement is not to break a valid URL. Exception: 
> relative URLs.
> 
> additional test case:
> 
>          d = Link( 'mail' )
>          d.edit( 'mailto:user@foo.com' )
>          self.assertEqual( d.getRemoteUrl(), 'mailto:user@foo.com' )
> 
> <mailto:pass@foo.com> and <http://mailto:pass@foo.com> are both valid 
> URLs. But <mailto:pass@foo.com> should not be changed to 
> <http://mailto:pass@foo.com> .
> If you don't want to test the scheme name (and I wouldn't), you can't 
> fix <user:pass@foo.com> to <http://user:pass@foo.com>.
> 
> 2) Next priority is fixing invalid URLs. If the value could be a valid 
> absolute URL, we don't care to break a valid relative URL.
> 
> test cases:
> 
> If you want to fix <www.foo.com>, <baz.com>, <baz2.com/index.html>, 
> <hmmm.com/lol.txt> etc., you'll change also <index.html> to 
> <http://index.html>, <folder/file.txt> to <http://folder/file.txt>. 
> That's not nice, but you can't avoid it.
> 
> 3) The rest should not be touched or it should be discarded.
> 
> I think these 3 test cases don't make any sense.
> 
>          d = Link( 'zoinx' )
>          d.edit( '/huh/zoinx.html' )
>          self.assertEqual( d.getRemoteUrl(), 'http:/huh/zoinx.html' )
> 
>          d = Link('foo', remote_url='/baz.org/zoinx/')
>          self.assertEqual(d.getRemoteUrl(), 'http:/baz.org/zoinx/')
> 
>          d = Link('foo')
>          d.edit('/baz.com/foo/')
>          self.assertEqual(d.getRemoteUrl(), 'http:/baz.com/foo/')
> 
> Ciao,
> 	Yuppie
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com