URL: https://github.com/peterbe/premailer/commit/4535dd6ce39c09a7bd3b39190cab6fea9882c16b

I just pushed out a new release of premailer which comes with a pretty big change.

What it means is that the way the base_url and any href= or src= gets combined. For example, you used to be able to set Premailer(html, base_url='http://example.com/subfolder') and combined with <img src="/images/foo.png"> it would become <img src="http://example.com/subfolder/images/foo.png">.

Not any more. The joining works exactly like the Python built-in urljoin() works. E.g.


>>> from urllib.parse import urljoin  # python 3
>>> urljoin('https://example.com', '/image.png')
'https://example.com/image.png'
>>> urljoin('https://example.com/subfolder', '/image.png')
'https://example.com/image.png'
>>> urljoin('https://example.com/subfolder/', '/image.png')
'https://example.com/image.png'
>>> urljoin('https://example.com/subfolder/', '//image.png')
'https://image.png'
>>> urljoin('https://example.com/subfolder/', '//mycdn.com/image.png')
'https://mycdn.com/image.png'
>>> urljoin('http://example.com/subfolder/', '//mycdn.com/image.png')
'http://mycdn.com/image.png'
>>> urljoin('https://example.com/subfolder', 'image.png')
'https://example.com/image.png'
>>> urljoin('https://example.com/subfolder/', 'image.png')
'https://example.com/subfolder/image.png'

So basically, if you think you tried to do something odd with your base_url check it over carefully when you upgrade to version 2.9.0.

Thank you @ewjoachim and @graingert for your help!

Comments

Your email will never ever be published.

Previous:
Use closure for your Django context processors May 9, 2015 Python, Django
Next:
Python slow-down of exception handling or condition checking May 14, 2015 Python
Related by category:
A Python dict that can report which keys you did not use June 12, 2025 Python
In Python, you have to specify the type and not rely on inference October 10, 2025 Python
Native connection pooling in Django 5 with PostgreSQL June 25, 2025 Python
Combining Django signals with in-memory LRU cache August 9, 2025 Python
Related by keyword:
Premailer.io July 8, 2015 Python, Web development, AngularJS, JavaScript
premailer.py - Transform CSS into line style attributes with lxml.html July 11, 2009 Python
premailer now excludes pseudo selectors by default May 27, 2013 Python, Web development
How to use premailer as a command line script July 13, 2012 Python