Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function convertDebuggerPathToClient(
fileUri: string | url.Url,
pathMapping?: { [index: string]: string }
): string {
let localSourceRoot: string | undefined
let serverSourceRoot: string | undefined
if (typeof fileUri === 'string') {
fileUri = url.parse(fileUri)
}
// convert the file URI to a path
let serverPath = decode(fileUri.pathname!)
// strip the trailing slash from Windows paths (indicated by a drive letter with a colon)
const serverIsWindows = /^\/[a-zA-Z]:\//.test(serverPath)
if (serverIsWindows) {
serverPath = serverPath.substr(1)
}
if (pathMapping) {
for (const mappedServerPath of Object.keys(pathMapping)) {
const mappedLocalSource = pathMapping[mappedServerPath]
// normalize slashes for windows-to-unix
const serverRelative = (serverIsWindows ? path.win32 : path.posix).relative(mappedServerPath, serverPath)
if (serverRelative.indexOf('..') !== 0) {
serverSourceRoot = mappedServerPath
localSourceRoot = mappedLocalSource
break
}
}
function saveFile (data, fileName, cb) {
const mimeType = data.hapi.headers['content-type']
const name = fileName || urlencode.decode(data.hapi.filename, 'utf8')
const file = data
const filePath = path.join(uploadPath, name)
const fileStream = fs.createWriteStream(filePath)
const fileInfo = {
mimeType,
name,
path: filePath,
extension: Mime.extension(mimeType)
}
fileStream.on('error', (err) => {
if (err && err.errno === 34) {
// Still not sure if throw is the best to go here
log(['error'], new Error(
'Error while saving file, possible issue with path - ' +
err
function saveFile (kind, data, cb) {
const mimeType = data.hapi.headers['content-type']
const fileInfo = {
id: kind + '_' + Math.random().toString(36).substr(2, 20),
kind: kind,
name: urlencode.decode(data.hapi.filename)
}
const file = data
const path = config.upload.path + '/' + fileInfo.id
const fileStream = fs.createWriteStream(path)
fileStream.on('error', (err) => {
if (err && err.errno === 34) {
log.error('[file] issue with file path')
}
log.error({err: err}, '[file] error uploading file')
return cb(Boom.internal())
})
file.pipe(fileStream)
file.on('end', (err) => {
export function urlDecode(url):string{
return urlencode.decode(url);
}
getInfoUrl(resultsId) {
const { baseUrl } = this.config
return baseUrl + urlencode.decode(resultsId)
}
getInfoUrl(resultsId) {
const { baseUrl } = this.config
return baseUrl + urlencode.decode(resultsId)
}
.forEach(link => {
const normalizedLink = path.join(this.webRoot, resolveUrl(linkInfo.path, encode.decode(link), this.base));
if (!this.pathVariants.some(pathVariant => allValidReferences[normalizedLink + pathVariant])) {
unmatchedLinks.push(link);
}
});
const originAddressList = children.map(url => urlencode.decode(url));
const addressList = originAddressList.filter(url => this._isMatch(config, url));
componentDidUpdate: function() {
var cm = this.refs.codeMirror.editor;
var exampleName = urlencode.decode(this.getParams().exampelName);
if (exampleName) {
for (var {name: n, code: c } of this.state.examples) {
if (n === exampleName) {
if (cm && c !== cm.getValue()) {
this.showingExample = true;
cm.setValue(c);
this.showingExample = false;
}
break;
}
}
}
var {traceIter, syntaxError, syntaxHighlight} = this.state;
if (traceIter) {
var trace = traceIter.getCurrentTrace();
getInfoUrl(resultsId) {
return this._absoluteUrl(urlencode.decode(resultsId))
}
}