Skip to content
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

These functions shouldn't be in utils #463

Open
kasbah opened this issue Oct 25, 2022 · 0 comments
Open

These functions shouldn't be in utils #463

kasbah opened this issue Oct 25, 2022 · 0 comments
Labels

Comments

@kasbah
Copy link
Member

kasbah commented Oct 25, 2022

Seems like these are very readme processing specific and should have gone there.

export function isRelativeUrl(uri: string) {
return !uri.match(/^https?:\/\//)
}
export function normalizeRelativeUrl(url: string, rootFolder: string) {
if (url.startsWith('/')) {
return url.slice(1)
}
return path.join(rootFolder, url)
}
export function toGitHubRawUrl(url: string) {
const parsedUrl = new URL(url)
if (parsedUrl.hostname === 'github.com') {
parsedUrl.hostname = 'raw.githubusercontent.com'
const urlPath = parsedUrl.pathname.split('/')
// Remove `/blob/` or '/raw/' from the path.
parsedUrl.pathname = urlPath.slice(0, 3).concat(urlPath.slice(4)).join('/')
url = parsedUrl.toString()
}
return url
}

@AbdulrhmnGhanem AbdulrhmnGhanem added this to the alpha-2 milestone Oct 27, 2022
@kasbah kasbah removed this from the alpha-2 milestone Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants