Skip to content

Commit 38edb3f

Browse files
committed
fix: Relative URLs are not working with authenticated fetch
1 parent 509d21b commit 38edb3f

1 file changed

Lines changed: 34 additions & 21 deletions

File tree

app/routes/index.js

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,12 @@ export default class IndexRoute extends Route {
144144
async removeN3RulesFromResource() {
145145
const fetch = this.solidAuth.session.fetch;
146146

147-
const response = await fetch(this.loadedFormUri, {
148-
method: 'GET',
149-
});
147+
const response = await fetch(
148+
new URL(this.loadedFormUri, await this.solidAuth.podBase).href,
149+
{
150+
method: 'GET',
151+
}
152+
);
150153

151154
// Get content-type.
152155
const contentType = response.headers.get('content-type');
@@ -169,13 +172,16 @@ export default class IndexRoute extends Route {
169172
});
170173

171174
// Save resource without N3 rules.
172-
await fetch(this.loadedFormUri, {
173-
method: 'PUT',
174-
headers: {
175-
'Content-Type': contentType,
176-
},
177-
body: text,
178-
});
175+
await fetch(
176+
new URL(this.loadedFormUri, await this.solidAuth.podBase).href,
177+
{
178+
method: 'PUT',
179+
headers: {
180+
'Content-Type': contentType,
181+
},
182+
body: text,
183+
}
184+
);
179185

180186
return { rules, prefixes };
181187
}
@@ -184,9 +190,12 @@ export default class IndexRoute extends Route {
184190
const { rules, prefixes } = matches;
185191
const fetch = this.solidAuth.session.fetch;
186192

187-
const response = await fetch(this.loadedFormUri, {
188-
method: 'GET',
189-
});
193+
const response = await fetch(
194+
new URL(this.loadedFormUri, await this.solidAuth.podBase).href,
195+
{
196+
method: 'GET',
197+
}
198+
);
190199

191200
// Get content-type.
192201
const contentType = response.headers.get('content-type');
@@ -211,13 +220,16 @@ export default class IndexRoute extends Route {
211220
});
212221

213222
// Save resource with N3 rules.
214-
await fetch(this.loadedFormUri, {
215-
method: 'PUT',
216-
headers: {
217-
'Content-Type': contentType,
218-
},
219-
body: text,
220-
});
223+
await fetch(
224+
new URL(this.loadedFormUri, await this.solidAuth.podBase).href,
225+
{
226+
method: 'PUT',
227+
headers: {
228+
'Content-Type': contentType,
229+
},
230+
body: text,
231+
}
232+
);
221233
}
222234

223235
async fillInFormWithSubmitEventPolicy(matches) {
@@ -253,7 +265,8 @@ export default class IndexRoute extends Route {
253265
type: 'stringSource',
254266
value: reasonerResult,
255267
mediaType: 'text/n3',
256-
baseIRI: this.loadedFormUri,
268+
baseIRI: new URL(this.loadedFormUri, await this.solidAuth.podBase)
269+
.href,
257270
},
258271
],
259272
})

0 commit comments

Comments
 (0)