w3up
w3up copied to clipboard
Issue with relative paths in subfolders on w3s.link
bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq is a folder containing 10 subfolders, each of which is a static archive of MIT OpenCourseware material. There is no index.html in the root, but there is in each subfolder.
When I load one of the subfolder sites in the w3s gateway, the CSS doesn't load, and the links don't work: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020
However, CSS and links work correctly on the dweb.link gateway: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/
I think this is because they are relative links in the HTML, and the w3s gateway is interpreting that as relative to the root, rather than relative to the subfolder. For example, when I click on the syllabus link in the w3s gateway, I get directed to https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/pages/syllabus/index.html, which doesn't exist.
But in the dweb.link gateway the same link takes me to https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html, which is the correct path.
That path does exist on the w3s gateway, so if it was linked to correctly the site would work as expected: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html, and weirdly enough the CSS loads fine there.
Interesting - it looks like at least one of the root causes here is a difference in redirect behavior between w3s.link and dweb.link - when I look at
https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link
and
https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link
I see that they both give me links with no trailing slash, like
https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020
and
https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020
but when I click on the links, dweb.link automatically adds a trailing slash, while w3s.link does not:
@alanshaw do you remember any quirks like this around trailing slashes? do you think it would be a problem for us to adopt dweb.link's behavior and automatically redirect to urls with trailing slashes? I'm not entirely convinced it's even the right thing to do, but curious about whether we've considered this before.
I noticed they don't add a trailing slash on all of them. This link, for example, was to the index.html file directly and so didn't get it tacked on: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html
I think it only makes sense to automatically add the trailing slash if the path being linked to is a directory.
https://github.com/storacha/gateway-lib/pull/66