Skip to content

Commit

Permalink
Merge pull request #15642 from webpack/set-use-credentials-without-or…
Browse files Browse the repository at this point in the history
…igin-check

set crossOrigin=use-credentials without origin check
  • Loading branch information
sokra authored Jul 25, 2022
2 parents fcb0e35 + 8729f2e commit 402d152
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
16 changes: 9 additions & 7 deletions lib/css/CssLoadingRuntimeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ class CssLoadingRuntimeModule extends RuntimeModule {
'link.rel = "stylesheet";',
"link.href = url;",
crossOriginLoading
? Template.asString([
"if (link.src.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
),
"}"
])
? crossOriginLoading === "use-credentials"
? 'link.crossOrigin = "use-credentials";'
: Template.asString([
"if (link.src.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`link.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
),
"}"
])
: ""
]);

Expand Down
16 changes: 9 additions & 7 deletions lib/runtime/LoadScriptRuntimeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
: "url"
};`,
crossOriginLoading
? Template.asString([
"if (script.src.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
),
"}"
])
? crossOriginLoading === "use-credentials"
? 'script.crossOrigin = "use-credentials";'
: Template.asString([
"if (script.src.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`script.crossOrigin = ${JSON.stringify(crossOriginLoading)};`
),
"}"
])
: ""
]);

Expand Down
20 changes: 11 additions & 9 deletions lib/web/JsonpChunkLoadingRuntimeModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,17 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
'link.as = "script";',
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
crossOriginLoading
? Template.asString([
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`link.crossOrigin = ${JSON.stringify(
crossOriginLoading
)};`
),
"}"
])
? crossOriginLoading === "use-credentials"
? 'link.crossOrigin = "use-credentials";'
: Template.asString([
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
Template.indent(
`link.crossOrigin = ${JSON.stringify(
crossOriginLoading
)};`
),
"}"
])
: ""
]),
chunk
Expand Down

0 comments on commit 402d152

Please sign in to comment.