feat: pathname 允许只有一个 /

This commit is contained in:
suxiaoxin 2017-12-07 14:29:24 +08:00
parent e8c95ee139
commit 290f8c5505
6 changed files with 33 additions and 12 deletions

View File

@ -4,6 +4,7 @@
1. Api 路径兼容 postman {varible}
2. View Response Height 问题
3. pathname 允许只有一个 /
### v1.2.8

View File

@ -3,6 +3,8 @@ import PropTypes from 'prop-types'
import { Tree } from 'antd';
import { connect } from 'react-redux';
import { fetchVariableParamsList } from '../../reducer/modules/interfaceCol.js'
const TreeNode = Tree.TreeNode;
const CanSelectPathPrefix = 'CanSelectPath-';
@ -29,26 +31,42 @@ class VariablesSelect extends Component {
static propTypes = {
click: PropTypes.func,
currColId: PropTypes.number,
fetchVariableParamsList: PropTypes.func
fetchVariableParamsList: PropTypes.func,
id: PropTypes.number
}
state = {
records: [],
expandedKeys: []
}
handleRecordsData(id){
let newRecords = [];
this.id = id;
for(let i=0; i< this.records.length; i++){
if(this.records[i]._id === id){
break;
}
newRecords.push(this.records[i])
}
this.setState({
records: newRecords
})
}
async componentDidMount() {
const { currColId, fetchVariableParamsList } = this.props
let result = await fetchVariableParamsList(currColId);
let result = await fetchVariableParamsList(currColId);
let records = result.payload.data.data;
records = records.sort((a, b)=>{
this.records = records.sort((a, b)=>{
return a.index - b.index
})
this.setState({
records
})
this.handleRecordsData(this.props.id)
}
async componentWillReceiveProps(nextProps){
if(this.records && nextProps.id &&this.id !== nextProps.id ){
this.handleRecordsData(nextProps.id)
}
}
handleSelect = (key) => {

View File

@ -37,7 +37,8 @@ class ModalPostman extends Component {
handleCancel: PropTypes.func,
handleOk: PropTypes.func,
inputValue: PropTypes.any,
envType: PropTypes.string
envType: PropTypes.string,
id: PropTypes.number
}
constructor(props) {
@ -191,7 +192,7 @@ class ModalPostman extends Component {
envType === 'case' && <Panel
header={<h3 className="mock-title">变量&nbsp;<Tooltip placement="top" title="YApi 提供了强大的变量参数功能,你可以在测试的时候使用前面接口的 参数 或 返回值 作为 后面接口的参数,即使接口之间存在依赖,也可以轻松 一键测试~"><Icon type="question-circle-o" /></Tooltip></h3>}
key="3">
<VariablesSelect click={this.mockClick(index)} />
<VariablesSelect id={this.props.id} click={this.mockClick(index)} />
</Panel>
}
</Collapse>

View File

@ -248,6 +248,7 @@ export default class Run extends Component {
handleOk={this.handleModalOk}
inputValue={inputValue}
envType={this.props.type}
id={+this.state._id}
>
</ModalPostman>
<CheckCrossInstall hasPlugin={hasPlugin} />

View File

@ -1,6 +1,6 @@
{
"name": "yapi",
"version": "1.2.8",
"version": "1.2.9",
"description": "YAPI",
"main": "index.js",
"scripts": {

View File

@ -192,7 +192,7 @@ exports.handleVarPath = (pathname, params)=>{
* path第一位必需为 /, path 只允许由 字母数字-/_:.{}=
*/
exports.verifyPath = (path) => {
if (/^\/[a-zA-Z0-9\-\/_:\.\{\}\=]+$/.test(path)) {
if (/^\/[a-zA-Z0-9\-\/_:\.\{\}\=]*$/.test(path)) {
return true;
} else {
return false;