Fix broken contract link on static about page#116
Conversation
There's an issue with the /static/about page. The underlying html is @src/static-files/about.html ; when I click the link `<a id="distribution-link" href="contract">"Distribution License Agreement"</a>` in a browser (links) with disabled js. It works correctly. But in chrome based browsers something interferes. To give a concrete example https://dspace-dev.ufal.mff.cuni.cz/repository/static/about and clicking the link takes me to https://dspace-dev.ufal.mff.cuni.cz/static/contract (but when I hover over the link I see the correct https://dspace-dev.ufal.mff.cuni.cz/repository/contract).
Now all non-fragment, non-dot-relative, non-external links on static pages use the normal app-root internal-link flow
|
@amadulhaxxani seems there's an issue with the "dot relative" links. See the static/about page and Terms of Service link. In js enabled browsers it eventually takes you to the right place (although if you hover over the link it doesn't look like it will). In JS disabled browsers you end up on 404 page. Thoughts? I'm thinking - should we explicitly add And similarly for the fragments? |
amadulhaxxani
left a comment
There was a problem hiding this comment.
I think you’re right to flag it.
I wouldn’t add static/ to everything though.
Maybe:
Use explicit app paths for app pages (like contract, licenses, terms), so they work with and without JS
Keep dot-relative links only for true static-to-static navigation.
For fragments: use #section for same page, and full path + #section for cross Page anchors.
So the fix is mostly about making intent explicit per link type, not globally adding static/
|
I think it's the base element in the html head that "confuses" things. Same page #section seems to resolve to baseurl#section. And similar with the "static" links. We should be able to fix the links when no js is involved, by fixing the relative links - providing |
StaticPageComponent: simplify link handling to only intercept dot-relative links and resolve them against the static page base URL; removed fragment/external/internal redirection helpers and related code paths. Updated unit tests to reflect the new interception behavior (dot-relative under static route, nested relative resolution, and no interception for fragments or explicit app routes). Updated multiple static HTML files (English and Czech) to prefix internal anchors and links with the static/ path so they resolve correctly when served via the static route.
There was a problem hiding this comment.
Pull request overview
This PR addresses incorrect navigation from static HTML pages by simplifying how StaticPageComponent intercepts clicks, and updates static HTML content to use the correct license route.
Changes:
- Refactors
StaticPageComponent.processLinksto only intercept dot-relative links (./,../) and correctly resolve the UI namespace. - Updates
StaticPageComponentunit tests (including a helper to simulate nested click targets) and aligns test config toui.nameSpace. - Updates static HTML pages to replace
no_static_licenseswithlicensesand adjusts several internal links.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/static-page/static-page.component.ts | Simplifies link interception to avoid breaking app-route links like contract under namespaced deployments. |
| src/app/static-page/static-page.component.spec.ts | Updates config key to nameSpace and adds tests for nested targets + dot-relative link handling. |
| src/static-files/about.html | Updates license link and rewrites a number of internal links. |
| src/static-files/cs/about.html | Updates license link and rewrites a number of internal links (Czech). |
| src/static-files/faq.html | Updates license link and rewrites a number of internal links. |
| src/static-files/cs/faq.html | Updates license link and rewrites a number of internal links (Czech). |
| src/static-files/item-lifecycle.html | Updates license link and rewrites a number of internal links. |
| src/static-files/cs/item-lifecycle.html | Updates license link and rewrites a number of internal links (Czech). |
|
@kosarko copilot's comments seem unrelated as I don't experience any reload especially the fragment links. Others are expected to reload as are static pages. If you agree I can just resolve the comments with short replies! |
|
@amadulhaxxani that's an interesting point it makes - not sure if that's a valid claim though. But even if that was valid, I guess, an extra page load is better than a broken link. So let's move on with this |
Normalize internal links across static HTML pages to use consistent paths and avoid broken relative references. Replaced occurrences of leading ./ and ../ for routes like discover and contract, and updated fragment links to use static/... (e.g. item-lifecycle, metadata, hplt-dataset-license-1.0). Affected files: src/static-files/cs/deposit.html, src/static-files/cs/faq.html, src/static-files/cs/metadata.html, src/static-files/deposit.html, src/static-files/faq.html, src/static-files/hplt-dataset-license-1.0.html, src/static-files/metadata.html.
This pull request improves internal link handling for static pages and updates license-related links in static HTML content. The main changes include refactoring the
StaticPageComponent's link processing logic for greater robustness and consistency, and updating static files to use the correct license link.Improvements to link handling in
StaticPageComponent:processLinksmethod to robustly resolve anchor elements from events, handle nested elements, and consistently build URLs based on the configured namespace. This ensures all internal, relative, and fragment links are handled correctly, and simplifies the code by removing the unusedno_static_prefix logic.nameSpaceproperty, matching the main application configuration.Content updates in static HTML files:
no_static_licenseslink in both English and Czech static HTML files to the correctlicenseslink, ensuring users are directed to the right page for license information. [1] [2] [3] [4] [5] [6]Code cleanup:
no_static_fromStaticPageComponent.Problem description
<a id="distribution-link" href="contract">"Distribution License Agreement"</a>in a browser (links) with disabled js. It works correctly. But in chrome based browsers something interferes. To give a concrete example https://dspace-dev.ufal.mff.cuni.cz/repository/static/about and clicking the link takes me to https://DOMAIN/static/contract (but when I hover over the link I see the correct https://DOMAIN/repository/contract).