fix: add FetchProxy
This will let us intercept fetch requests (until now we're only proxying
XMLHttpRequest), in order to fix the issues we're experiencing with some
features.
Bug: twpowertools:229
Change-Id: I277473c05479ca39bb6183a51855382124890bde
diff --git a/src/xhrInterceptor/fetchProxy/FetchInput.ts b/src/xhrInterceptor/fetchProxy/FetchInput.ts
new file mode 100644
index 0000000..75be8b8
--- /dev/null
+++ b/src/xhrInterceptor/fetchProxy/FetchInput.ts
@@ -0,0 +1,16 @@
+export default class FetchInput {
+ constructor(private input: RequestInfo | URL) {}
+
+ /**
+ * Returns the fetch input URL as a string.
+ */
+ getUrl() {
+ if (typeof this.input === 'string') {
+ return this.input;
+ } else if (this.input instanceof URL) {
+ return this.input.toString();
+ } else {
+ return this.input.url;
+ }
+ }
+}