mirror of https://github.com/docker/docs.git
Check URL parameters via regexp
Signed-off-by: Jeffrey Morgan <jmorganca@gmail.com>
This commit is contained in:
parent
902a0e5763
commit
6679f9a851
|
|
@ -7,6 +7,7 @@ var util = require('./Util');
|
|||
var metrics = require('./Metrics');
|
||||
var Router = require('react-router');
|
||||
var ContainerStore = require('./ContainerStore');
|
||||
var dialog = require('remote').require('dialog');
|
||||
|
||||
var ContainerHomeFolder = React.createClass({
|
||||
mixins: [Router.State, Router.Navigation],
|
||||
|
|
@ -16,20 +17,27 @@ var ContainerHomeFolder = React.createClass({
|
|||
});
|
||||
|
||||
if (hostVolume.indexOf(process.env.HOME) === -1) {
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
var newHostVolume = path.join(util.home(), 'Kitematic', this.props.container.Name, containerVolume);
|
||||
volumes[containerVolume] = newHostVolume;
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
return pair[1] + ':' + pair[0];
|
||||
});
|
||||
ContainerStore.updateContainer(this.props.container.Name, {
|
||||
Binds: binds
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
dialog.showMessageBox({
|
||||
message: 'Enable all volumes to edit files via Finder? This may not work with all database containers.',
|
||||
buttons: ['Enable Volumes', 'Cancel']
|
||||
}, (index) => {
|
||||
if (index === 0) {
|
||||
var volumes = _.clone(this.props.container.Volumes);
|
||||
var newHostVolume = path.join(util.home(), 'Kitematic', this.props.container.Name, containerVolume);
|
||||
volumes[containerVolume] = newHostVolume;
|
||||
var binds = _.pairs(volumes).map(function (pair) {
|
||||
return pair[1] + ':' + pair[0];
|
||||
});
|
||||
ContainerStore.updateContainer(this.props.container.Name, {
|
||||
Binds: binds
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
return;
|
||||
}
|
||||
shell.showItemInFolder(newHostVolume);
|
||||
});
|
||||
}
|
||||
shell.showItemInFolder(newHostVolume);
|
||||
});
|
||||
} else {
|
||||
shell.showItemInFolder(hostVolume);
|
||||
|
|
|
|||
15
src/Main.js
15
src/Main.js
|
|
@ -34,6 +34,8 @@ ipc.on('application:quitting', opts => {
|
|||
});
|
||||
|
||||
ipc.on('application:open-url', opts => {
|
||||
var repoRegexp = /[a-z0-9]+(?:[._-][a-z0-9]+)*/;
|
||||
var tagRegexp = /[\w][\w.-]{0,127}/;
|
||||
var parser = document.createElement('a');
|
||||
parser.href = opts.url;
|
||||
|
||||
|
|
@ -44,10 +46,15 @@ ipc.on('application:open-url', opts => {
|
|||
var pathname = parser.pathname.replace('//', '');
|
||||
var tokens = pathname.split('/');
|
||||
var type = tokens[0];
|
||||
var method = tokens[1];
|
||||
var repo = tokens.slice(2).join('/');
|
||||
if (type === 'repository' && method === 'run') {
|
||||
ContainerStore.setPending(repo, parser.tag || 'latest');
|
||||
var repo = tokens.slice(1).join('/');
|
||||
var tag = parser.tag || 'latest';
|
||||
|
||||
if (repo.indexOf('/') !== -1 || !repoRegexp.test(repo) || !tagRegexp.test(tag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === 'repository') {
|
||||
ContainerStore.setPending(repo, tag);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = React.createClass({
|
|||
<div className="details">
|
||||
<div className="new-container-pull">
|
||||
<div className="content">
|
||||
<h1>You're about to download <a onClick={this.handleOpenClick}>{this.props.pending.repository}</a>.</h1>
|
||||
<h1>You're about to download and run <a onClick={this.handleOpenClick}>{this.props.pending.repository}:{this.props.pending.tag}</a>.</h1>
|
||||
<h1>Please confirm to create the container.</h1>
|
||||
<div className="buttons">
|
||||
<a className="btn btn-action" onClick={this.handleCancelClick}>Cancel</a> <a onClick={this.handleConfirmClick} className="btn btn-action">Confirm</a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue