Skip to content

Conversation

@marinaaisa
Copy link
Member

Bug/issue #165347857, if applicable:

Summary

We want to normalize Sample Code URLs, by adding the baseUrl to them if the path is relative and the baseUrl is provided. If the path is absolute or the baseUrl is not provided, it does not prefixes the URL.

Because the component CallToActionButton.vue is not only being used for Sample Code links, we created a new prop called linksToAsset that will normalize the relative URLs, in the cases that they are assets, like Sample Code.

Dependencies

NA

Testing

Steps:

  1. Provide a baseUrl
  2. Go to a page for Sample Codes that points to a relative path
  3. Assert that the link gets prefixed with the baseUrl

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

It prefixes the URL with the baseUrl value if the path is relative and
the baseUrl is provided. If the path is absolute or the baseUrl is not
provided, it does not prefixes the URL.
We only want to normalize the URL in the case that it links to an asset,
that's why in this commit we introduce a new boolean prop for the
CallToActionButton called `linksToAsset`.
Now that we have the prop linksToAsset available for
CallToActionButton components, we want to pass it as true for the
download button used for Sample Codes, since the URL links to an asset.
@marinaaisa marinaaisa requested a review from mportiz08 November 24, 2025 17:09
We want to use this function to check if urls are absolute or not.
For the normalizePath function to work, the path needs to be relative.
This means that we need to normalize the relative path first, to make
sure that the normalizePath function reads it as a relative path.

For this, we should use the function isAbsoluteUrl to see if the url is
absolute or not.
We want to make sure that simple-relative paths like 'foo/bar' also work
when prefixing the baseUrl.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant