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
How I run standalone Python in 2025 January 14, 2025 Python
How to resolve a git conflict in poetry.lock February 7, 2020 Python
get in JavaScript is the same as property in Python February 13, 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
Premailer 3.0.0 - classes kept by default June 7, 2016 Python, Web development