#61909 closed defect (bug) (fixed)
Script Loader: Do not normalize absolute-paths in `_wp_normalize_relative_css_links()`.
Reported by: | scholdstrom | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.7 | Priority: | normal |
Severity: | normal | Version: | trunk |
Component: | Script Loader | Keywords: | has-patch has-unit-tests |
Focuses: | css | Cc: |
Description
Currently _wp_normalize_relative_css_links()
normalizes all non-absolute URLs regardless if it's a relative-path or an absolute-path. The normalization should only happen for relative-paths (paths without a leading /) and not for absolute paths.
See RFC1808, Section 4, Step 4 and since it's against this RFC I'll classify this as a bug but it could just as likely be classified as a feature.
Currently using an absolute path would normalize the URL like this
-'p {background:url( "/image0.svg" );}' +'p {background:url( "/wp-content/themes/test//image0.svg" );}'
Theme developers referencing urls in CSS would always use relative links so that hostname isn't fixed at build time. At the moment theme developers wanting to support wp_maybe_inline_styles()
have to use relative paths and would not be able to set a base path for assets with Webpack publicPah option. I believe this is required for using webpack lazy loaded chunks.
I do believe this is more commonly used by agencies building websites.
Attachments (1)
Change History (5)
This ticket was mentioned in PR #7228 on WordPress/wordpress-develop by oxyc.
3 weeks ago
#1
- Keywords has-patch has-unit-tests added
#3
@
3 weeks ago
- Owner set to SergeyBiryukov
- Resolution set to fixed
- Status changed from new to closed
In 58932:
@SergeyBiryukov commented on PR #7228:
3 weeks ago
#4
Thanks for the PR! Merged in r58932.
Currently _wp_normalize_relative_css_links() normalizes all non-absolute URLs regardless if it's a relative-path or an absolute-path. The normalization should only happen for relative-paths (paths without a leading /) and not for absolute paths.
Trac ticket: https://core.trac.wordpress.org/ticket/61909