Refactor of URL Handling and Deprecation of relative attribute in auro-hyperlink
#608
alexisiba
started this conversation in
Technical Research Documents
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Overview
The
auro-hyperlinkcomponent is responsible for rendering internal and external links consistently across the Alaska Airlines design system.Currently, it includes a
relativeattribute intended to distinguish between internal (relative) and external (absolute) links. However, the a tag used internally already performs this detection automatically, leading to redundant logic and unexpected behavior.Problem Statement
Current behavior:
https://alaskaair.comhrefdoes not start withhttp://orhttps://, the component concatenates the default base URL to it.relativeattribute is used to prevent that concatenation, forcing the link to remain "as is"Issues observed
relativeattribute adds complexity and confusion since the a tag already has logic to detect link types.relativewithtarget="_blankcauses rendering errors and the component crashes entirelyRoot cause analysis
The core issue stem from the coupling between:
relativeflagThe default URL injection assumes that all relative paths should be resolved to
https://alaskaair.comwhich may not align with application routing or expected behaviorProposed solution
Summary
Simplify URL handling logic by removing the default URL dependency and handling relative vs absolute URL explicitly.
Implementation steps
The component should not automatically prepend https://alaskaair.com to relative URLs
Checks whether the provided href is a valid absolute URL using the URL constructor
If the URL is relative, pass it directly to the element without any modifications
If the URL is absolute but incomplete or missing protocol, normalize it using:
ensuring a secure
httpsprotocol by default.relativeattribute.target="_blank"and other HTML anchor attributes./book/flights)https://example.com)Expected Behavior after change
<auro-hyperlink href="/book/flights" /><a href="HOST_NAME/book/flights">e.g. If domain is https://www.alaskaair.com it should render<a href="https://www.alaskaair.com/book/flights" ><auro-hyperlink href="https://alaskaair.com/flights" /><a href="https://alaskaair.com/flights">e.g. If you're using the component in https://www.hawaiianairlines.com/ it should render<a href="https://www.alaskaair.com/book/flights" ><auro-hyperlink href="alaskaair.com" /><a href="https://alaskaair.com/flights">. Note: We do not support programmatically handling invalid protocolstarget="_blank"<auro-hyperlink href="https://alaskaair.com" target="_blank" />Risks and mitigation
Acceptance criteria
relativeattribute should no longer be required to control link resolution.https://alaskaair.com) must be removed.Benefits
Questions for review
relativeattribute, or keep it temporarily as deprecated for backward compatibility?mailto:,tel:orftp:as external links?new URL()constructor?Conclusions from TRD Review Meeting
During the review meeting, the following key points and decisions were discussed
The component must work correctly across all environments, regardless of the domain in which it is used. This includes ensuring consistent behavior in both testing and auro.alaskaair.com environments.
1.1. Developers should be able to use the component seamlessly in a local environment (localhost) without configuration issues or restrictions.
This approach ensures backward compatibility while providing developers with greater flexibility and control over component behavior.
Beta Was this translation helpful? Give feedback.
All reactions