[wp-trac] [WordPress Trac] #61909: Script Loader: Do not normalize absolute-paths in `_wp_normalize_relative_css_links()`.
WordPress Trac
noreply at wordpress.org
Thu Aug 22 15:16:04 UTC 2024
#61909: Script Loader: Do not normalize absolute-paths in
`_wp_normalize_relative_css_links()`.
---------------------------+-----------------------------
Reporter: scholdstrom | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Script Loader | Version: trunk
Severity: normal | Keywords:
Focuses: css |
---------------------------+-----------------------------
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 [https://www.rfc-editor.org/rfc/rfc1808#section-4 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
{{{#!diff
-'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
[https://webpack.js.org/guides/public-path/ 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.
-
[https://github.com/roots/sage/blob/5cd2c43847c529cab13cab394a9551276f5523a8/bud.config.js#L26
Sage]
- [https://github.com/10up/10up-
toolkit/blob/8b74e5a02bdedc2e62b03d338c119629be2afd14/packages/toolkit/README.md?plain=1#L210
10up-toolkit]
- [https://github.com/search?q=publicPath%3A+%22%2Fwp-
content%2Fthemes%22+language%3AJavaScript&type=code&l=JavaScript GitHub
wide search]
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61909>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list