Skip to content

Commit a919d08

Browse files
committed
perf: exit early
1 parent c65135d commit a919d08

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ const createGetData = fetch => async (url, opts) => {
3030
e => e.attributes.findIndex(a => a.value === 'resource') !== -1
3131
)
3232

33-
const hydrateScript = scripts.filter(
34-
e => e.children[0] && /%22data%22%|"data":/.test(e.children[0].content)
35-
)
36-
3733
if (resourceScript.length > 0) {
3834
// found data in the older embed style
3935
return JSON.parse(decodeURIComponent(resourceScript[0].children[0].content))
4036
}
4137

38+
const hydrateScript = scripts.filter(
39+
e => e.children[0] && /%22data%22%|"data":/.test(e.children[0].content)
40+
)
41+
4242
if (hydrateScript.length > 0) {
4343
// found hydration data
4444
// parsing via looking for { to be a little bit resistant to code changes

0 commit comments

Comments
 (0)