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

Support loading of relative URLs #224

Closed
jasomimo opened this issue May 12, 2022 · 2 comments · Fixed by #279
Closed

Support loading of relative URLs #224

jasomimo opened this issue May 12, 2022 · 2 comments · Fixed by #279
Labels

Comments

@jasomimo
Copy link
Contributor

jasomimo commented May 12, 2022

Feature Description

When a relative URL is passed into codeFromUrl pipe, then file is not fetched.

<pre>
    <code [highlight]="'/assets/examples/foo.html' | codeFromUrl | async"></code>
</pre>

Let's say user would like to fetch a file from assets folder, but don't want to build full URL (maybe there is too many examples in assets, or they don't know on which domain will be the app deployed to).

If codeFromUrl pipe would support relative paths, it would be possible to reference the file only by a path which is starting from the assets folder. And that path would never change.

HighlightOptions interface might be enriched with baseUrl: string configuration option, where user could set the base path for relative URLs, e.g. https://example.com/my-app.

Use Case

This would allow to more easily reference files deployed on the same domain.

@exodussystem
Copy link

exodussystem commented Jan 22, 2023

I would like to have the same feature as well.

Basically if the module provides a way to set URL patterns that can be used in this function, then it should be fine

[code-loader.ts]
function isUrl(url: string) {
const regExp = /(ftp|http|https)://(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(/|/([\w#!:.?+=&%@!-/]))?/;
return regExp.test(url);
}

@MurhafSousli
Copy link
Owner

Fixed in v11, you can now use relative path like this

<pre>
    <code [highlight]="'assets/examples/foo.html' | codeFromUrl | async"></code>
</pre>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants