Skip to content

Commit

Permalink
fix(indent): 后行断言部分浏览器暂不支持
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jul 14, 2020
1 parent e311059 commit 3262fa0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/utils/dedent.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dedent } from './dedent'
import { indent } from './indent'

describe(dedent.name, () => {
describe('dedent', () => {
test('空字符串正常', () => {
expect(dedent``).toBe('')
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils/indent.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { indent } from './indent'

describe(indent.name, () => {
describe('indent', () => {
test('空字符串正常', () => {
expect(indent``).toBe('')
})
Expand Down
6 changes: 4 additions & 2 deletions src/utils/indent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ export function indent(
const match = literal.match(/(?:^|[\r\n]+)([^\S\r\n]*)$/)
if (match && match[1]) {
interpolation = interpolation.replace(
/(?<=[\r\n]+)(?=[^\r\n])/g,
match[1],
// fix: 后行断言部分浏览器暂不支持
// /(?<=[\r\n]+)(?=[^\r\n])/g,
/([\r\n]+)(?=[^\r\n])/g,
`$1${match[1]}`,
)
}
result += literal
Expand Down

0 comments on commit 3262fa0

Please sign in to comment.