Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : isStandardSyntaxUrl.js
'use strict';

const hasLessInterpolation = require('../utils/hasLessInterpolation');
const hasPsvInterpolation = require('../utils/hasPsvInterpolation');
const hasScssInterpolation = require('../utils/hasScssInterpolation');
const hasTplInterpolation = require('../utils/hasTplInterpolation');

/**
 * Check whether a URL is standard
 *
 * @param {string} url
 * @returns {boolean}
 */
module.exports = function (url) {
	if (url.length === 0) {
		return true;
	}

	// Sass interpolation works anywhere
	if (hasScssInterpolation(url) || hasTplInterpolation(url) || hasPsvInterpolation(url)) {
		return false;
	}

	// Inside `'` and `"` work only LESS interpolation
	if ((url.startsWith(`'`) && url.endsWith(`'`)) || (url.startsWith(`"`) && url.endsWith(`"`))) {
		if (hasLessInterpolation(url)) {
			return false;
		}

		return true;
	}

	// Less variable works only at the beginning
	// Check is less variable, allow use '@url/some/path'
	// https://github.com/less/less.js/blob/3.x/lib/less/parser/parser.js#L547
	if (url.startsWith('@') && /^@@?[\w-]+$/.test(url)) {
		return false;
	}

	// In url without quotes scss variable can be everywhere
	// But in this case it is allowed to use only specific characters
	// Also forbidden "/" at the end of url
	if (url.includes('$') && /^[$\s\w+-/*'"/]+$/.test(url) && !url.endsWith('/')) {
		return false;
	}

	return true;
};
© 2026 GrazzMean