Skip to content

Commit

Permalink
hack to clean up urls on vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthkp committed Mar 31, 2022
1 parent 2f07c80 commit db4d183
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/babel-plugin-open-source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-open-source",
"version": "1.3.1",
"version": "1.3.2",
"description": "Alt + Click on rendered JSX to open it's source code in VSCode",
"main": "babel.js",
"keywords": [],
Expand Down
13 changes: 12 additions & 1 deletion packages/babel-plugin-open-source/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,17 @@ if (typeof document !== 'undefined') {
event.preventDefault();
modifier = false;
const { url } = JSON.parse(event.target.dataset.source);
window.open(url);

if (!url.includes('https://github.com')) window.open(url);
else {
// TODO: I bet I'll regret hardcoding this
const cleanUrl = url
.replace('/vercel/path0/', '')
.replace('/vercel/path1/', '')
.replace('/vercel/path2/', '')
.replace('/vercel/path3/', '')
.replace('/vercel/path4/', '');
window.open(cleanUrl);
}
});
}

1 comment on commit db4d183

@vercel
Copy link

@vercel vercel bot commented on db4d183 Mar 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.