小编Tho*_*ggi的帖子

strip_tags()函数黑名单而不是白名单

我最近发现了一个strip_tags()函数,它接受一个字符串和一个接受的html标签列表作为参数.

让我们说我想摆脱字符串中的图像这里是一个例子:

$html = '<img src="example.png">';
$html = '<p><strong>This should be bold</strong></p>';
$html .= '<p>This is awesome</p>';
$html .= '<strong>This should be bold</strong>';

echo strip_tags($html,"<p>");
Run Code Online (Sandbox Code Playgroud)

返回:

<p>This should be bold</p>
<p>This is awesome</p>
This should be bold
Run Code Online (Sandbox Code Playgroud)

因此我通过<strong>也许<em>将来摆脱了格式化.

我想要一种黑名单的方法,而不是像白名单那样的白名单:

echo blacklist_tags($html,"<img>");
Run Code Online (Sandbox Code Playgroud)

返回:

<p><strong>This should be bold<strong></p>
<p>This is awesome</p>
<strong>This should be bold<strong>
Run Code Online (Sandbox Code Playgroud)

有没有办法做到这一点?

php

6
推荐指数
1
解决办法
1805
查看次数

没有提交就推

我有一个git repo,我把它推到服务器上.然后我在服务器上设置了一个post-receive挂钩.我想检查它是否有效.我必须再次承诺,看它是否有效?我真的想在我试图建立这个设置时强行推动,而不是继续进行没有实际价值的提交.它不起作用,我只是不明白.

$ git push --force origin master
Everything up-to-date
Run Code Online (Sandbox Code Playgroud)

git

6
推荐指数
1
解决办法
4500
查看次数

POST请求应该呈现HTML还是重定向?

POST请求应该呈现HTML还是重定向?

我讨厌你在页面上刷新并让浏览器告诉你,你将再次发布数据.

post http

6
推荐指数
2
解决办法
2129
查看次数

所有测试都通过 100% 覆盖率,但 jest 返回退出代码 1

我研究过--detectLeaks--detectOpenHandles,它确实引发了一些错误,但输出中没有明显的问题。

\n\n

我有一个 monorepo,我正在 docker/管道中的 jenkins 中运行 jest。

\n\n
> abide@1.0.0 jest /var/jenkins_home/workspace/abide\n> jest --coverage --no-cache --runInBand\n\n[BABEL] Note: The code generator has deoptimised the styling of "/var/jenkins_home/workspace/abide/node_modules/lodash/lodash.js" as it exceeds the max of "500KB".\nPASS packages/help.parse-argv/index.test.js (10.842s)\n[BABEL] Note: The code generator has deoptimised the styling of "/var/jenkins_home/workspace/abide/node_modules/text-encoding/lib/encoding-indexes.js" as it exceeds the max of "500KB".\nhello\nnpm notice created a lockfile as package-lock.json. You should commit this file.\n+ example-working@0.0.1\nadded 2 packages from 2 contributors and audited 2 packages in 2.837s\nfound …
Run Code Online (Sandbox Code Playgroud)

jestjs

6
推荐指数
1
解决办法
5195
查看次数

Typescript lint“no-unused-vars”与声明的元组

我有一行代码,如下所示:

const [full, text, url] = markdownLink.exec(match) || [null, null, '']
Run Code Online (Sandbox Code Playgroud)

但是我没有使用full,并且 linter 给了我一个警告。

第 28 行:“full”被赋值但从未使用过

我想像这样声明元组,但我不需要full。有没有一种语法方法可以通过跳过完整来解决这个问题?

tuples typescript eslint tslint

6
推荐指数
2
解决办法
1655
查看次数

在 webpack 构建中包含本地包 (turborepo)

我有两个包uiapp在一个使用turborepo的“monorepo”中。

我有带有文件的 ui 存储库.tsx,但它没有被构建,它package.json main是一个打字稿文件。

但是,在运行时,nextjs我在从主文件导入时遇到错误ui

是否可以node_modulenextjs角度考虑这一点?当我查看时,config.module.rule我找不到打字稿文件的任何规则。我不确定 nextjs 文件的打字稿配置如何。

next.js turborepo

6
推荐指数
1
解决办法
1万
查看次数

服务器上有多个github私有npm存储库

我在私有存储库中的github上有一个节点应用程序.此节点应用程序还具有我制作的自定义模块,它们位于单独的专用存储库中.

这是示例节点应用程序URL:

git@github.com:thomas/node-application.git
Run Code Online (Sandbox Code Playgroud)

这些都是节点应用程序使用的节点模块.

git@github.com:thomas/node-module1.git
git@github.com:thomas/node-module2.git
Run Code Online (Sandbox Code Playgroud)

您可以使用以下命令在github上安装私有npm模块.

npm install git+ssh://git@github.com:thomas/node_module1.git
Run Code Online (Sandbox Code Playgroud)

为了使其工作,机器需要设置ssh键.

我的本地机器设置了我的github用户密钥并访问我的所有回购.

在我的服务器上,但是我正在使用部署密钥.我知道如何使用多个部署密钥的唯一方法如下.

Host na.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
ForwardAgent yes

Host nm1.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module1
ForwardAgent yes

Host nm2.github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

所以我需要在服务器上安装模块

npm install git+ssh://git@nm1.github.com:thomas/node_module1.git
                          ^^^
Run Code Online (Sandbox Code Playgroud)

这意味着生产和开发的依赖性会有所不同

"node-module": "git+ssh://git@github.com:thomas/node-module1.git"
Run Code Online (Sandbox Code Playgroud)

VS

"node-module": "git+ssh://git@nm1.github.com:thomas/node-module1.git"
                              ^^^
Run Code Online (Sandbox Code Playgroud)

如果我可以做这样的事情,这可能会奏效......

Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/gh_node-application
IdentityFile ~/.ssh/gh_node-module1
IdentityFile ~/.ssh/gh_node-module2
ForwardAgent yes
Run Code Online (Sandbox Code Playgroud)

ssh github node.js npm

5
推荐指数
1
解决办法
1561
查看次数

写下承诺而不打开然后打电话

为了努力停止编写大量重复的代码,我试图不打开然后调用.我最好只喜欢从顶层传递函数.像这样.

function ensureLink(srcPath, dstPath){
  dstPath = fsRedux.predictDir(srcPath, dstPath)
  var dstDir = path.dirname(dstPath)
  return fsRedux.exists(dstPath)
    .then(_.partialRight(fsRedux.ifFalseThrow, false, new Error(dstPath+" exists cannot ensure link")))
    .then(_.bind(fsExtra.mkdirsAsync, fsExtra, dstDir))
    .then(_.bind(_.bind(fsExtra.linkAsync, fsExtra, srcPath, dstPath)))
}
Run Code Online (Sandbox Code Playgroud)

但是上面的代码不起作用.下面的测试表明您无法通过bound promisifyAll异步功能.原因是then值被传递到这些promises中,导致它们作为调用中的下一个参数,因为这些函数意味着它们作为回调触发,这就是为什么第一个测试错误出现Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.在mocha中.

var chai = require("chai")
var chaiAsPromised = require("chai-as-promised")
chai.use(chaiAsPromised)
chai.should()

var path = require("path")
var _ = require("lodash")
var mock = require("mock-fs")

var Promise = require("bluebird")
var fsRedux = require("./fs-redux") …
Run Code Online (Sandbox Code Playgroud)

javascript function promise lodash bluebird

5
推荐指数
1
解决办法
175
查看次数

npm:ENOENT:没有这样的文件或目录

我正在使用npm 3.3.6,当我尝试安装大量模块时,出现以下错误:

npm i babel-cli babel-plugin-syntax-async-functions babel-plugin-transform-regenerator babel-polyfill babel-preset-es2015 babelify watchify browserify --save-dev

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/thomas/.nvm/versions/node/v5.0.0/bin/node" "/Users/thomas/.nvm/versions/node/v5.0.0/bin/npm" "i" "babel-cli" "babel-plugin-syntax-async-functions" "babel-plugin-transform-regenerator" "babel-polyfill" "babel-preset-es2015" "babelify" "watchify" "browserify" "--save-dev"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! path /Users/thomas/Desktop/esnext-bootstrap/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents/node_modules/asn1
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/Users/thomas/Desktop/esnext-bootstrap/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents/node_modules/asn1' -> '/Users/thomas/Desktop/esnext-bootstrap/node_modules/asn1'
npm ERR! enoent This is most likely not a …
Run Code Online (Sandbox Code Playgroud)

rename npm babeljs

5
推荐指数
1
解决办法
6748
查看次数

lerna 在 Jenkins 上发布“git 远程更新”失败“无法从远程存储库读取。”

我正在尝试在所有测试通过后进行发布lernajenkins我已经运行了该命令,但失败了。

我找不到任何有关如何使其发挥作用的文档。我需要这个命令才能将 lerna 标签以及更新的版本号推送到 master 分支,并且我还需要 Jenkins 不要陷入无限循环。

我的第一个问题是这样的:

> lerna publish --yes --cd-version=patch

lerna info version 3.0.0-beta.17
lerna info versioning independent
lerna ERR! ENOGIT Detached git HEAD, please checkout a branch to publish changes.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! abide@1.0.0 publish: `lerna publish --yes --cd-version=patch`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the abide@1.0.0 publish script.
npm ERR! This is probably not a problem with npm. …
Run Code Online (Sandbox Code Playgroud)

git github node.js jenkins lerna

5
推荐指数
1
解决办法
5417
查看次数