Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (turbolinks) {
const tq = this
tq.replaceTimer = 0
tq.appendTimer = 0
tq.turbolinks = turbolinks || Turbolinks || false
if (!tq.turbolinks || !tq.turbolinks.supported) {
console.error('No passed or global Turbolinks instance detected. TurboQuery requires Turbolinks.')
return
}
// These are timer callbacks. Bind them to the TurboQuery instance.
tq.replaceHistory = tq._replaceHistory.bind(tq)
tq.appendHistory = tq._appendHistory.bind(tq)
tq.url = Url(window.location.href, true)
}
if (assetUrlOverride) {
const uri = path.join(assetUrlOverride, hash);
return { uri: resolveUri(uri), hash };
}
const fileScale = scale === 1 ? '' : `@${scale}x`;
const fileExtension = meta.type ? `.${encodeURIComponent(meta.type)}` : '';
const suffix = `/${encodeURIComponent(meta.name)}${fileScale}${fileExtension}?platform=${encodeURIComponent(Platform.OS)}&hash=${encodeURIComponent(meta.hash)}`;
// For assets with a specified absolute URL, we use the existing origin instead of prepending the
// development server or production CDN URL origin
if (/^https?:\/\//.test(meta.httpServerLocation)) {
const uri = meta.httpServerLocation + suffix;
return { uri, hash };
}
// For assets during development, we use the development server's URL origin
if (Constants.manifest && Constants.manifest.developer) {
const baseUrl = new URL(Constants.manifest.bundleUrl);
baseUrl.set('pathname', meta.httpServerLocation + suffix);
return { uri: baseUrl.href, hash };
}
// Production CDN URIs are based on each asset file hash
return {
uri: `https://d1wp6m56sqw74a.cloudfront.net/~assets/${encodeURIComponent(hash)}`,
hash,
};
}
/**
chrome.webRequest.onBeforeSendHeaders.addListener(details => {
const {tabId, initiator, requestHeaders} = details;
const fromHelper = !_.isEmpty(_.find(requestHeaders, ({name, value}) => name === 'From' && value === 'bilibili-helper'));
if (/^chrome-extension:\/\//.test(initiator) || fromHelper) {
return;
}
const url = new Url(details.url, '', true);
const {query} = url;
if (query && query.requestFrom) return;
const tabData = this.messageStore.createData(tabId);
fetchFromHelper(url.href)
.then(res => res.json())
.then((res) => {
tabData.queue.push({
command: 'showDisabledVideoURLRequest',
data: res,
});
this.messageStore.dealWith(tabId); // 处理queue
});
}, requestFilter, ['requestHeaders']);
};
export function sanitizeURL(url: ?string): ?string {
if (url == null) {
return url;
}
const proto = URL(url).protocol;
// allow http, https, ftp
// IMPORTANT: Don't allow data: protocol because of:
// <a>here</a>
if (proto === 'https:' || proto === 'http:' || proto === 'ftp:') {
return url;
}
return undefined;
}
.map(item => {
const url = parse(item.part);
const parts = parse(url.hash.replace('#', '?'), true);
const [x, y, width, height] = parts.query.xywh.split(',').map(Number);
url.set('hash', null);
const src = url.toString();
return {
start: Math.trunc(item.start / 1000),
src,
x,
y,
width,
height,
};
})
.sort((a, b) => b.start - a.start);
getUrlObject () {
const { asPath } = this.props.router
return new Url(asPath, true)
}
getUrlObject () {
const { asPath } = this.props.router
return new Url(asPath, true)
}
export default function urlVerification(url) {
const urlRecord = new URL(url);
const { pathname, protocol, hash } = urlRecord;
if (!url) {
throw new TypeError(`${ERROR_PREFIX.CONSTRUCTOR_ERROR} 1 argument required, but only 0 present.`);
}
if (!pathname) {
urlRecord.pathname = '/';
}
if (protocol === '') {
throw new SyntaxError(`${ERROR_PREFIX.CONSTRUCTOR_ERROR} The URL '${urlRecord.toString()}' is invalid.`);
}
if (protocol !== 'ws:' && protocol !== 'wss:') {
throw new SyntaxError(
function parseHostFromUrl(url) {
const parsedURL = new URL(url);
return parsedURL.host;
}
export function resolveUri(uri) {
if (!manifestBaseUrl) {
return uri;
}
const { protocol } = new URL(uri);
if (protocol !== '') {
return uri;
}
const baseUrl = new URL(manifestBaseUrl);
const resolvedPath = uri.startsWith('/') ? uri : path.join(baseUrl.pathname, uri);
baseUrl.set('pathname', resolvedPath);
return baseUrl.href;
}
//# sourceMappingURL=AssetSources.js.map