Repository: facebook/react
File: packages/react-devtools-shared/src/symbolicateSource.js (JavaScript)

Code before:
          const consumer = SourceMapConsumer(parsedSourceMap);
          const {
            sourceURL: possiblyURL,
            line,
            column,
          } = consumer.originalPositionFor({
            lineNumber, // 1-based
            columnNumber, // 1-based
          });

          if (possiblyURL === null) {
            return null;
          }
          try {
            // sourceMapURL=https://...
            void new URL(possiblyURL); // test if it is a valid URL
            const normalizedURL = normalizeUrl(possiblyURL);

            return {sourceURL: normalizedURL, line, column};
          } catch (e) {
            // This is not valid URL
            if (
              // sourceMapURL=/file
              possiblyURL.startsWith('/') ||
              // sourceMapURL=C:\\...
              possiblyURL.slice(1).startsWith(':\\\\')
            ) {
              // This is an absolute path
              return {sourceURL: possiblyURL, line, column};
            }

            // This is a relative path
            // sourceMapURL=x.js.map
            const absoluteSourcePath = new URL(
              possiblyURL,
              sourceMapURL,
            ).toString();
            return {sourceURL: absoluteSourcePath, line, column};
          }
        } catch (e) {
          return null;
        }
      }

      return null;
    }
  }

  return null;
}


Review comment (suggestion):
```suggestion
              // sourceMapURL = /file
              possiblyURL.startsWith('/') ||
              // sourceMapURL = C:\\...
              possiblyURL.slice(1).startsWith(':\\\\')
```

Code after:
          const consumer = SourceMapConsumer(parsedSourceMap);
          const {
            sourceURL: possiblyURL,
            line,
            column,
          } = consumer.originalPositionFor({
            lineNumber, // 1-based
            columnNumber, // 1-based
          });

          if (possiblyURL === null) {
            return null;
          }
          try {
            // sourceMapURL = https://react.dev/script.js.map
            void new URL(possiblyURL); // test if it is a valid URL
            const normalizedURL = normalizeUrl(possiblyURL);

            return {sourceURL: normalizedURL, line, column};
          } catch (e) {
            // This is not valid URL
            if (
              // sourceMapURL = /file
              possiblyURL.startsWith('/') ||
              // sourceMapURL = C:\\...
              possiblyURL.slice(1).startsWith(':\\\\')
            ) {
              // This is an absolute path
              return {sourceURL: possiblyURL, line, column};
            }

            // This is a relative path
            // possiblyURL = x.js.map, sourceMapURL = https://react.dev/script.js.map
            const absoluteSourcePath = new URL(
              possiblyURL,
              sourceMapURL,
            ).toString();
            return {sourceURL: absoluteSourcePath, line, column};
          }
        } catch (e) {
          return null;
        }
      }

      return null;
    }
  }

  return null;
}