Server IP : 108.163.255.210 / Your IP : 3.14.247.170 Web Server : Apache System : Linux blossom.urlnameserver.com 3.10.0-1160.80.1.el7.x86_64 #1 SMP Tue Nov 8 15:48:59 UTC 2022 x86_64 User : ( 1172) PHP Version : 7.2.34 Disable Function : eval,escapeshellarg,proc_close,proc_get_status,proc_nice,proc_open,symlink,system,pcntl_exec,getrusage,chown,chgp,closelog,openlog,syslog,define_syslog_variables,php_ini_loaded_file,getservbyname,getservbyport,posix_getgid,posix_getgrgid,proc_terminate,pfsockopen,apache_child_terminate,posix_mkfifo,posix_setpgid,posix_setuid,hypot,pg_host,pos,posix_access,posix_getcwd,posix_getservbyname,myshellexec,getpid,posix_getsid,posix_isatty,posix_kill,posix_mknod,posix_setgid,posix_setsid,posix_setuid,posix_times,posix_uname,ps_fill,posix_getpwuid,global,ini_restore,zip_open,zip_read,rar_open,bzopen,bzread,bzwrite,apache_get_modules,apache_get_version,phpversionphpinfo,php_ini_scanned_files,get_current_user,disk_total_space,diskfreespace,leak,imap_list,hypo,filedump,safe_mode,getmygid,apache_getenv,apache_setenv,bzread,bzwrite,bzopen,phpini,higlight_file,dos_conv,get_cwd,er_log,cmd,e_name,vdir,get_dir,only_read,ftok,ftpexec,posix_getpwnam,mysql_list_dbs,disk_free_space,session_save_path,confirm_phpdoc_compiled,zip_entry_rea,php_u,psockopen,crack_opendict,crack_getlastmessage,crack_closedict,crack_check,fpassthru,posix_get_last_error,posix_getlogin,posix_getgroups,posix_strerror,posix_getrlimit,posix_getpgrp,posix_getgrnam,pos,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/unilinki/public_html/indijourneys.com/node_modules/svgo/plugins/ |
Upload File : |
'use strict'; exports.type = 'perItem'; exports.active = false; exports.params = { delim: '__' }; exports.description = 'prefix IDs'; var path = require('path'), csstree = require('css-tree'), cssRx = require('css-url-regex'), unquote = require('unquote'), collections = require('./_collections.js'), referencesProps = collections.referencesProps, rxId = /^#(.*)$/, // regular expression for matching an ID + extracing its name addPrefix = null; // Escapes a string for being used as ID var escapeIdentifierName = function(str) { return str.replace(/[\. ]/g, '_'); }; // Matches an #ID value, captures the ID name var matchId = function(urlVal) { var idUrlMatches = urlVal.match(rxId); if (idUrlMatches === null) { return false; } return idUrlMatches[1]; }; // Matches an url(...) value, captures the URL var matchUrl = function(val) { var urlMatches = cssRx().exec(val); if (urlMatches === null) { return false; } return urlMatches[1]; }; // Checks if attribute is empty var attrNotEmpty = function(attr) { return (attr && attr.value && attr.value.length > 0); }; // prefixes an #ID var prefixId = function(val) { var idName = matchId(val); if (!idName) { return false; } return '#' + addPrefix(idName); }; // attr.value helper methods // prefixes a class attribute value var addPrefixToClassAttr = function(attr) { if (!attrNotEmpty(attr)) { return; } attr.value = attr.value.split(/\s+/).map(addPrefix).join(' '); }; // prefixes an ID attribute value var addPrefixToIdAttr = function(attr) { if (!attrNotEmpty(attr)) { return; } attr.value = addPrefix(attr.value); }; // prefixes a href attribute value var addPrefixToHrefAttr = function(attr) { if (!attrNotEmpty(attr)) { return; } var idPrefixed = prefixId(attr.value); if (!idPrefixed) { return; } attr.value = idPrefixed; }; // prefixes an URL attribute value var addPrefixToUrlAttr = function(attr) { if (!attrNotEmpty(attr)) { return; } // url(...) in value var urlVal = matchUrl(attr.value); if (!urlVal) { return; } var idPrefixed = prefixId(urlVal); if (!idPrefixed) { return; } attr.value = 'url(' + idPrefixed + ')'; }; /** * Prefixes identifiers * * @param {Object} node node * @param {Object} opts plugin params * @param {Object} extra plugin extra information * * @author strarsis <strarsis@gmail.com> */ exports.fn = function(node, opts, extra) { // prefix, from file name or option var prefix = 'prefix'; if (opts.prefix) { if (typeof opts.prefix === 'function') { prefix = opts.prefix(node, extra); } else { prefix = opts.prefix; } } else if (opts.prefix === false) { prefix = false; } else if (extra && extra.path && extra.path.length > 0) { var filename = path.basename(extra.path); prefix = filename; } // prefixes a normal value addPrefix = function(name) { if(prefix === false){ return escapeIdentifierName(name); } return escapeIdentifierName(prefix + opts.delim + name); }; // <style/> property values if (node.elem === 'style') { if (node.isEmpty()) { // skip empty <style/>s return node; } var cssStr = node.content[0].text || node.content[0].cdata || []; var cssAst = {}; try { cssAst = csstree.parse(cssStr, { parseValue: true, parseCustomProperty: false }); } catch (parseError) { console.warn('Warning: Parse error of styles of <style/> element, skipped. Error details: ' + parseError); return node; } var idPrefixed = ''; csstree.walk(cssAst, function(node) { // #ID, .class if ((node.type === 'IdSelector' || node.type === 'ClassSelector') && node.name) { node.name = addPrefix(node.name); return; } // url(...) in value if (node.type === 'Url' && node.value.value && node.value.value.length > 0) { idPrefixed = prefixId(unquote(node.value.value)); if (!idPrefixed) { return; } node.value.value = idPrefixed; } }); // update <style>s node.content[0].text = csstree.generate(cssAst); return node; } // element attributes if (!node.attrs) { return node; } // ID addPrefixToIdAttr(node.attrs.id); // Class addPrefixToClassAttr(node.attrs.class); // href addPrefixToHrefAttr(node.attrs.href); // (xlink:)href (deprecated, must be still supported) addPrefixToHrefAttr(node.attrs['xlink:href']); // referenceable properties for (var referencesProp of referencesProps) { addPrefixToUrlAttr(node.attrs[referencesProp]); } return node; };