@shopify/hydrogen 2023.10.3 → 2023.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -457,7 +457,7 @@ var warnOnce = (string) => {
457
457
  };
458
458
 
459
459
  // src/version.ts
460
- var LIB_VERSION = "2023.10.3";
460
+ var LIB_VERSION = "2023.10.4";
461
461
 
462
462
  // src/utils/graphql.ts
463
463
  function minifyQuery(string) {
@@ -843,7 +843,7 @@ async function storefrontRedirect(options) {
843
843
  const searchParams = new URLSearchParams(search);
844
844
  const redirectTo = searchParams.get("return_to") || searchParams.get("redirect");
845
845
  if (redirectTo) {
846
- if (isLocalPath(redirectTo)) {
846
+ if (isLocalPath(request.url, redirectTo)) {
847
847
  return serverRuntime.redirect(redirectTo);
848
848
  } else {
849
849
  console.warn(
@@ -859,8 +859,12 @@ async function storefrontRedirect(options) {
859
859
  }
860
860
  return response;
861
861
  }
862
- function isLocalPath(url) {
863
- return !/^(([a-z+-]+:)?\/\/|[a-z+-]+:)/i.test(url.trim());
862
+ function isLocalPath(requestUrl, redirectUrl) {
863
+ try {
864
+ return new URL(requestUrl).origin === new URL(redirectUrl, requestUrl).origin;
865
+ } catch (e) {
866
+ return false;
867
+ }
864
868
  }
865
869
  var REDIRECT_QUERY = `#graphql
866
870
  query redirects($query: String) {