Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/core/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
* limitations under the License.
*/

export const PROTOCOL_REGEX = /^(data|ftps?|https?):/;

export type RGBA = [r: number, g: number, b: number, a: number];
export const getNormalizedRgbaComponents = (rgba: number): RGBA => {
const r = rgba >>> 24;
Expand Down Expand Up @@ -250,8 +252,8 @@ export function isRectPositive(rect: Rect): boolean {
}

export function convertUrlToAbsolute(url: string): string {
// handle local file imports
if (self.location.protocol === 'file:') {
// handle local file imports if the url isn't remote resource or data blob
if (self.location.protocol === 'file:' && !PROTOCOL_REGEX.test(url)) {
const path = self.location.pathname.split('/');
path.pop();
const basePath = path.join('/');
Expand Down