Skip to content

Service Worker precache_urls should respect --relative #499

@frnco

Description

@frnco

Currently it seems pretty much all URLs are properly relativized when --relative is set, except for the precache_urls used in the serviceworker. The relevar file is mint/src/utils/service_worker.cr, in line 21, inside the function precache_urls. Using #321 as a reference it seems it's just a matter of using that same path_for() function instead of just concatenating the initial /.
The current code:

    def precache_urls
      files
        .join(",\n") do |file|
          %('/#{file.relative_to(DIST_DIR)}')
        end
    end

I believe the change would result in something like:

    def precache_urls
      files
        .join(",\n") do |file|
          path_for(file.relative_to(DIST_DIR))
        end
    end

Is it really that simple or did I miss something? If it is, I believe it could be pretty useful when relative paths are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions