-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
on import link extensions make absolute urls relative #4877
base: main
Are you sure you want to change the base?
Conversation
1b3a211
to
ae2e639
Compare
packages/app/src/cli/services/admin-link/extension-to-toml.test.ts
Outdated
Show resolved
Hide resolved
b2d26db
to
bd01c9b
Compare
Coverage report
Show files with reduced coverage 🔻
Test suite run success1950 tests passing in 888 suites. Report generated by 🧪jest coverage report action from 68bf4b6 |
We detected some changes at packages/*/src and there are no updates in the .changeset. |
bd01c9b
to
5297a9c
Compare
2a816ca
to
83ee53c
Compare
/snapit |
🫰✨ Thanks @alfonso-noriega! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
83ee53c
to
68bf4b6
Compare
Unused dependencies (1)
Unused devDependencies (1)
Unused types (1)
|
const linkPath = linkUrl.pathname.startsWith('/') ? linkUrl.pathname.substring(1) : linkUrl.pathname | ||
const fullUrl = new URL(`app://${linkPath}`) | ||
fullUrl.search = linkUrl.search | ||
fullUrl.hash = linkUrl.hash | ||
config.url = fullUrl.toString() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When linkUrl.pathname
is /
(e.g., in https://example.com?foo=bar
), the current code will set linkPath
to an empty string, but the query parameters and hash fragment won't be preserved in the final URL. To fix this edge case, modify the pathname check:
const linkPath = linkUrl.pathname === '/' ? '' : linkUrl.pathname.substring(1)
This ensures query parameters and hash fragments are correctly preserved in URLs that point to the root path.
Spotted by Graphite Reviewer
Is this helpful? React 👍 or 👎 to let us know.
/snapit |
🫰✨ Thanks @alfonso-noriega! Your snapshot has been published to npm. Test the snapshot by intalling your package globally: pnpm i -g @shopify/[email protected]
|
WHY are these changes introduced?
The current process to create legacy link extensions in the partners dashboard enables to create non secure and external pointing absolute URLs for embedded apps. Those URLs are later on overwritten by core to point to the shop embedded app URL.
This behaviour fills the DB with incorrect URLs and the new CLI managed admin link extension is avoiding this pattern.
WHAT is this pull request doing?
To reduce friction on the partners migration, this code automatically ignores the domain of the embedded app legacy link extensions and transforms them into relative URLs.
How to test your changes?
From the CLI repo, checkout this branch.
Create a link extension in the partners dashboard with an absolute URL pointing to a random external domain (http://example.org/product).
In the CLI repo run the import extensions command:
pnpm shopify app import-extensions --path path-to-your-app
Select the admin links option
Check the the generated extension toml contains a url like
app://product
I've considered possible cross-platform impacts (Mac, Linux, Windows)
I've considered possible documentation changes