Skip to content

Commit

Permalink
Merge pull request #422 from GoogleChrome/revert-to-pwaid
Browse files Browse the repository at this point in the history
We are temporarly going back to URLs with ID
  • Loading branch information
juliantoledo authored Jun 16, 2017
2 parents 0bb7605 + c64d934 commit f7e0e6e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 23 deletions.
31 changes: 10 additions & 21 deletions controllers/pwa.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,26 +204,15 @@ router.post('/add', (req, res, next) => {
* Display a PWA or redirects to the encodedStartUrl of the PWA.
*/
router.get('/:pwa', (req, res, next) => {
if (isNaN(Number(req.params.pwa))) {
// This URL is not a number, assume encodedStartUrl.
renderOnePwa(req, res)
.then(html => {
res.send(html);
})
.catch(err => {
err.status = 404;
return next(err);
});
return;
}

// Otherwise, redirect to /pwas/<encodedStartUrl>.
pwaLib.find(req.params.pwa).then(pwa => {
res.redirect(301, req.baseUrl + '/' + pwa.encodedStartUrl);
}).catch(err => {
err.status = 404;
return next(err);
});
renderOnePwa(req, res)
.then(html => {
res.send(html);
})
.catch(err => {
err.status = 404;
return next(err);
});
return;
});

/**
Expand All @@ -233,7 +222,7 @@ function renderOnePwa(req, res) {
const url = req.originalUrl;
const pwaId = encodeURIComponent(req.params.pwa); // we have foo/ here, need foo%2F
const contentOnly = false || req.query.contentOnly;
return pwaLib.findByEncodedStartUrl(pwaId)
return pwaLib.find(pwaId)
.then(pwa => {
return lighthouseLib.findByPwaId(pwaId)
.then(lighthouse => {
Expand Down
2 changes: 1 addition & 1 deletion public/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ toolbox.options.debug = false;

importScripts('/js/sw-assets-precache.js'); /* global ASSETS */

const VERSION = '7';
const VERSION = '8';
const PREFIX = 'gulliver';
const CACHE_NAME = `${PREFIX}-v${VERSION}`;
const PWA_OPTION = {
Expand Down
2 changes: 1 addition & 1 deletion views/pwas/list.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<div class="items">
{{#each pwas}}
<a id="{{id}}" class="item card-pwa offline-aware gulliver-content-only box-shadow" href="/pwas/{{encodedStartUrl}}" style="background-color: {{backgroundColor}}; color:{{contrastColor backgroundColor}}">
<a id="{{id}}" class="item card-pwa offline-aware gulliver-content-only box-shadow" href="/pwas/{{id}}" style="background-color: {{backgroundColor}}; color:{{contrastColor backgroundColor}}">
{{#if iconUrl64}}
<img class="pwa-icon" src="{{iconUrl64}}" srcset="{{iconUrl64}} 1x, {{iconUrl128}} 2x" width="64" height="64" alt="logo for {{displayName}}"/>
{{else}}
Expand Down

0 comments on commit f7e0e6e

Please sign in to comment.