handle empty url path
This commit is contained in:
@@ -46,8 +46,11 @@ const URL_IN_CSS_REF = /url\((?:'([^']*)'|"([^"]*)"|([^)]*))\)/gm;
|
||||
const RELATIVE_PATH = /^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/).*/;
|
||||
const DATA_URI = /^(data:)([\w\/\+]+);(charset=[\w-]+|base64).*,(.*)/gi;
|
||||
export function absoluteToStylesheet(cssText: string, href: string): string {
|
||||
return cssText.replace(URL_IN_CSS_REF, (_1, path1, path2, path3) => {
|
||||
return cssText.replace(URL_IN_CSS_REF, (origin, path1, path2, path3) => {
|
||||
const filePath = path1 || path2 || path3;
|
||||
if (!filePath) {
|
||||
return origin;
|
||||
}
|
||||
if (!RELATIVE_PATH.test(filePath)) {
|
||||
return `url('${filePath}')`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user