我的客户端应用程序正在通过Firebase Functions创建的API访问Firestore。但是,Firebase Functions导入firebase-admin会绕过所有定义的安全规则。有什么方法可以使我的HTTP触发Function充当特定用户(例如,通过将访问令牌从客户端传递到服务器),从而使Function也可以在Firebase Functions的影响下工作。
node.js firebase google-cloud-functions firebase-admin google-cloud-firestore
var ts = "00:00:06,705";
var regularExpression = /([0-9]+):([0-9]{2}):([0-9]{2}),([0-9]{3})/g;
var parsedTs1 = regularExpression.exec(ts);
var parsedTs2 = regularExpression.exec(ts);
Run Code Online (Sandbox Code Playgroud)
parsedTs1 显示正确的结果,但运行此脚本后,parsedTs2 变量为 null。
但是当我们删除最后一个“g”字符时,效果很好。
根据文档,选项标志 g 表示全局搜索,与本例无关。
如何多次使用定义的正则表达式字符串来匹配字符串呢?
我的构造函数中React.Component有十多个bind(this)调用.
我不认为.bind(this)在构造函数中提供任何帮助来理解我的代码,尤其是在读取render()中的代码时.
所以,我提出了以下想法,但是,没有找到如何实现这一点.
render() {
if (this.methodToBind.getThis() === this) {
this.methodToBind = this.methodToBind.bind(this);
}
}Run Code Online (Sandbox Code Playgroud)
有没有可能的方法我可以得到一个方法(getThis()从上面的例子)?
如果是的话,这样做是不错的做法?