pdf.worker.min.js use absolute path instead of relative path

Summary

The embedded pdf.js pdf viewer of gitlab use the absolute path instead of relative path, which could lead to rendering error of pdf files on the gitlab instance that enabled relative URL.

Steps to reproduce

  1. Enable relative URL for an gitlab instance with the url like external_url "https://example.com/git"
  2. Try to view a pdf file on the gitlab instance.
  3. Got "An error occurred while loading the file. Please try again later." and found that the pdf.js got 404 on console.

Example Project

with the configuration:

external_url "https://mirrors.sustech.edu.cn/git"

https://mirrors.sustech.edu.cn/git/sustech-online/sustech-online-ng/-/blob/master/docs/calendar/2021-2022-excel.pdf

What is the current bug behavior?

Got "An error occurred while loading the file. Please try again later." and found that the pdf.js got 404 on console.

What is the expected correct behavior?

The pdf could be correctly rendered.

Relevant logs and/or screenshots

image image

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.7.7p221
Gem Version:	3.1.6
Bundler Version:2.3.15
Rake Version:	13.0.6
Redis Version:	6.2.8
Sidekiq Version:6.5.7
Go Version:	unknown

GitLab information
Version:	15.8.0
Revision:	c052f86b6b4
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	13.8
URL:		https://mirrors.sustech.edu.cn/git
HTTP Clone URL:	https://mirrors.sustech.edu.cn/git/some-group/some-project.git
SSH Clone URL:	***
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers: cas3, cas3_cra_sso

GitLab Shell
Version:	14.15.0
Repository storages:
- default: 	unix:/var/opt/gitlab/gitaly/gitaly.socket
GitLab Shell path:		/opt/gitlab/embedded/service/gitlab-shell

Possible fixes

https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/pdf/index.vue#L6

change the GlobalWorkerOptions.workerSrc from absolute path to relative path.

Edited Feb 13, 2023 by SUSTech Online
Assignee Loading
Time tracking Loading